azure - 无法使用 Azure 资源管理器模板的资源函数

标签 azure azure-devops azure-resource-manager azure-rm-template

我的参数文件如下所示:

    {
       "$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 的场景,您可以使用嵌套部署:

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-keyvault-parameter#reference-a-secret-with-dynamic-id

关于azure - 无法使用 Azure 资源管理器模板的资源函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50681605/

相关文章:

node.js - Azure 函数集 Node 版本

azure - 使用 ARM 模板将 UDR/路由表分配给子网

azure - 如何在Azure中授权池?

azure - Bicep - 数据工厂身份属性

Azure 设置订阅命令通过 shell 脚本失败,但无需 shell 脚本即可工作

angular - AADSTS70002 : The request body must contain the following parameter: 'client_secret or client_assertion'

azure - 如何在没有 zip 文件和内部文件夹的情况下部署代码 azure devops

Azure Key Vault 访问策略不适用于组

ubuntu - 在 Azure DevOps 中更新 Microsoft 托管代理上的 CMake

azure-devops - VSTS : Can I access the Build variables from Release definition?