我的参数文件如下所示:
{
"$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion":"1.0.0.0",
"parameters":{
"siteName":{
"value":"my-api-application"
},
"appServicePlanName":{
"value":"MyServicePlan"
},
"siteLocation":{
"value":"West US"
},
"vaultResourceGroup": {
"value":"my-vault-res-group"
},
"vaultName": {
"value":"my-keyvault"
},
"nodeEnv": {
"value":"development"
},
"adminPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/yyyyyyyy-xxxx-xxxx-xxxx-yyyyyyyy/resourceGroups/my-vault-res-group/providers/Microsoft.KeyVault/vaults/my-keyvault"
},
"secretName": "adminPassword"
}
}
}
}
adminPassword 值将从指定的 KeyVault 中获取,并具有特定的 id 。但是,我必须对“id”值进行硬编码。
据此link ,我可以使用这样的东西指定 id:
resourceId(subscription().subscriptionId, parameters('vaultResourceGroup'), 'Microsoft.KeyVault/vaults', parameters('vaultName'))]
但是,在使用上述语法/资源函数时,我在使用 VSTS 发布和部署我的应用服务时收到错误(我使用Azure 资源组部署 APP 部署任务)。错误是这样的:
The id must be of the following format:
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
不确定我做错了什么?
最佳答案
你没有做错什么,那是故意的。您必须在参数文件中使用文字resourceId(参数文件不允许使用函数)。
如果您有动态 KeyVault ID 的场景,您可以使用嵌套部署:
关于azure - 无法使用 Azure 资源管理器模板的资源函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50681605/