如何在另一个发布任务中使用 ARM“输出"值? [英] How do I use ARM 'outputs' values another release task?

查看:17
本文介绍了如何在另一个发布任务中使用 ARM“输出"值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ARM 模板,它的输出部分如下所示:

I have an ARM template that has and outputs section like the following:

"outputs": {
    "sqlServerFqdn": {
        "type": "string",
        "value": "[reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName]"
    },
    "primaryConnectionString": {
        "type": "string",
        "value": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('databaseName'), ';User Id=', parameters('administratorLogin'), '@', variables('sqlserverName'), ';Password=', parameters('administratorLoginPassword'), ';')]"
    },
    "envResourceGroup": {
        "type": "string",
        "value": "[parameters('hostingPlanName')]"
    }
}

我有一个使用模板的 Azure 资源组部署任务.然后我想在下一个任务中使用变量 $(sqlServerFqdn) 进行配置.该变量似乎不只是填充,我找不到任何告诉我如何在发布时使用输出"值的地方.

I have a Azure Resource Group Deployment task that uses the template. I then want to use the variable $(sqlServerFqdn) in the next task for configuration. The variable doesn't seem to just populate and I cannot find anywhere that tells me how to use 'outputs' values on release.

在此 ARM 模板运行后,我需要做什么才能填充变量以用于配置任务?例如,在 powershell 脚本任务或其他 ARM 模板的参数中.

What do I need to do to get the variable to populate for use in configuring tasks after this ARM template runs? An example would be in the parameters to a powershell script task or another ARM template.

推荐答案

2020 年 11 月,在此提交之后 - https://github.com/microsoft/azure-pipelines-tasks/commit/1173324604c3f61ce52cdcc999f6d4d7ea9ab8f9 ,这些变量可以直接用于管道中的后续任务(不需要powershell脚本!!)

In Nov 2020, after this commit - https://github.com/microsoft/azure-pipelines-tasks/commit/1173324604c3f61ce52cdcc999f6d4d7ea9ab8f9 , the variables could directly be used in the subsequent tasks in the pipeline (No powershell scripts required!!)

这就是步骤的样子 -

  1. 在 ARM 模板部署任务中,为高级"下拉菜单下的部署输出"部分提供任何引用名称.就我而言,我给了 armOutputVariable.

查看图片以获得视觉描述

现在要在后续任务中使用sqlServerFqdnvalue,只需以这种方式使用$(armOutputVariable.sqlServerFqdn.value)

Now to use the value of sqlServerFqdn in the subsequent tasks, simply use it in this manner $(armOutputVariable.sqlServerFqdn.value)

例如,假设我想用它来覆盖部署后的测试任务中的参数,以便我可以按以下方式使用它 -示例图片

For example, let's say I want to use it to override a parameter in my test task which follows the deployment so I can use it in the following manner - Example image

总结一下 ARM 中的所有输出都可以直接以这种方式用于后续步骤(确保在 ARM 模板部署步骤中分配引用名称)-

To summarize all the outputs in the ARM could be used in the further steps directly in this manner (make sure you assign a reference name in the ARM template deployment step) -

$(armOutputVariable.sqlServerFqdn.value)
$(armOutputVariable.sqlServerFqdn.type)
$(armOutputVariable.primaryConnectionString.value)
$(armOutputVariable.primaryConnectionString.type)
$(armOutputVariable.envResourceGroup.value)
$(armOutputVariable.envResourceGroup.type)

这篇关于如何在另一个发布任务中使用 ARM“输出"值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆