ARM 模板部署:重用参数文件中的任务参数
ARM template deployment : re-use task parameters in parameters file
我在发布管道中使用 ARM 模板部署任务。该任务有一个名为 Location
的参数。
在我的 parameters.json 文件中,我还有一个名为 Location
的参数。我怎样才能更改此文件,以便它读取任务本身设置的值?
当前值是从来自 azure keyvault 的变量组的变量中读取的。但我认为让这个位置参数来自保险库有点过分了。
Location*:
For Resource Group deployment scope: Location for deploying the resource group. If the resource group already exists in the subscription, then this value will be ignored.
For other deployment scopes: Location for storing the deployment metadata.
根据此信息,您可以通过任务设置资源组的位置,并将其用于您的所有资源。如果您希望资源位于与资源组不同的位置,您将无法利用任务参数。
这是它在 ARM 中的样子:
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
根据我的测试,我注意到 xxx.parameters.json 中的值无法读取管道中变量的值。
例如:
我在管道变量中设置了变量(test : abc)。然后我在 xxx.parameters.json 文件中使用它。
资源组创建时,不读取资源组中的变量
parameters.json样本:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"value": "test"
},
"location": {
"value": "$(test)"
}
}
}
从结果来看,似乎无法在 json 文件中自动使用位置值。
您可能需要使用 tokenizer
任务手动覆盖 json 文件中的特定值。然后该值可以在资源组中使用。
或者直接在ARM模板任务中使用Override template parameters
希望这对您有所帮助。
我在发布管道中使用 ARM 模板部署任务。该任务有一个名为 Location
的参数。
在我的 parameters.json 文件中,我还有一个名为 Location
的参数。我怎样才能更改此文件,以便它读取任务本身设置的值?
当前值是从来自 azure keyvault 的变量组的变量中读取的。但我认为让这个位置参数来自保险库有点过分了。
Location*:
For Resource Group deployment scope: Location for deploying the resource group. If the resource group already exists in the subscription, then this value will be ignored. For other deployment scopes: Location for storing the deployment metadata.
根据此信息,您可以通过任务设置资源组的位置,并将其用于您的所有资源。如果您希望资源位于与资源组不同的位置,您将无法利用任务参数。
这是它在 ARM 中的样子:
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
根据我的测试,我注意到 xxx.parameters.json 中的值无法读取管道中变量的值。
例如:
我在管道变量中设置了变量(test : abc)。然后我在 xxx.parameters.json 文件中使用它。 资源组创建时,不读取资源组中的变量
parameters.json样本:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"value": "test"
},
"location": {
"value": "$(test)"
}
}
}
从结果来看,似乎无法在 json 文件中自动使用位置值。
您可能需要使用 tokenizer
任务手动覆盖 json 文件中的特定值。然后该值可以在资源组中使用。
或者直接在ARM模板任务中使用Override template parameters
希望这对您有所帮助。