Azure ARM 模板 - 检查现有的 Key Vault 访问策略

Azure ARM template - check for existing Key Vault access policies

我正在查找以确定是否为给定的密钥保管库设置了任何访问策略,并将其用作模板中的条件。如果有 none,我想创建访问策略,否则应跳过创建。我怎样才能做到这一点?下面是我现在得到的,没有条件表达式。

{
  "comments": "Create an Azure Key Vault and add an access policy in the key vault for the webb app.",
  "type": "Microsoft.KeyVault/vaults",
  "name": "[parameters('KeyVaultName')]",
  "apiVersion": "2018-02-14",
  "location": "[resourceGroup().location]",
  "properties": {
    "enabledForDeployment": false,
    "enabledForTemplateDeployment": false,
    "enabledForVolumeEncryption": false,
    "tenantId": "[reference(variables('identity_resource_id'), '2018-11-01', 'Full').identity.tenantId]",
    "accessPolicies": [
      {
        "tenantId": "[reference(variables('identity_resource_id'), '2018-11-01', 'Full').identity.tenantId]",
        "objectId": "[reference(variables('identity_resource_id'), '2018-11-01', 'Full').identity.principalId]",
        "permissions": {
          "secrets": [ "get", "list" ]
        }
      }
    ],
    "sku": {
      "name": "standard",
      "family": "A"
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
  ]
},

您实际上无法使用 arm 模板检查任何内容,您需要将此检查具体化或始终应用它们。缺点是——如果你这样做,它会覆盖现有的。或者,您可以在模板中一个接一个地添加策略,这样可以同时解决这两个问题,有点。