【发布时间】:2021-07-01 04:32:56
【问题描述】:
我正在尝试通过 ARM 模板在预先存在的 Key Vault 上启用软删除(KV 是使用 ARM 预配的)。我检查了template reference documentation 并在模板中添加了enableSoftDelete 属性。
这是我的完整 ARM 模板:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"keyVault_name": {
"type": "string"
},
"keyVault_secrets": {
"type": "array"
},
"keyVault_location": {
"type": "string"
},
"accessPolicies": {
"type": "array"
},
"tenant": {
"type": "string"
},
"sku": {
"type": "string"
},
"redeploy_keyVault_Instance": {
"type": "bool"
},
"softDeleteRetentionPeriodInDays": {
"type": "int"
}
},
"variables": {},
"resources": [
{
"apiVersion": "2016-10-01",
"name": "[parameters('keyVault_name')]",
"location": "[parameters('keyVault_location')]",
"type": "Microsoft.KeyVault/vaults",
"properties": {
"enabledForDeployment": false,
"enabledForTemplateDeployment": true,
"enabledForDiskEncryption": false,
"accessPolicies": "[parameters('accessPolicies')]",
"enableSoftDelete": true,
"softDeleteRetentionInDays": "[parameters('softDeleteRetentionPeriodInDays')]",
"tenantId": "[parameters('tenant')]",
"sku": {
"name": "[parameters('sku')]",
"family": "A"
}
},
"condition": "[parameters('redeploy_keyVault_Instance')]"
},
{
"apiVersion": "2016-10-01",
"name": "[concat(parameters('keyVault_name'), '/', parameters('keyVault_secrets')[copyIndex()].secretName)]",
"type": "Microsoft.KeyVault/vaults/secrets",
"properties": {
"attributes": {
"enabled": true
},
"contentType": "string",
"value": "InvalidPassword"
},
"location": "[parameters('keyVault_location')]",
"copy": {
"name": "KeyVaultSecretCopy",
"count": "[length(parameters('keyVault_secrets'))]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', parameters('keyVault_name'))]"
],
"condition": "[parameters('keyVault_secrets')[copyIndex()].deployTemplate]"
}
]
}
尽管添加了属性,但当我导航到门户时,我看到软删除以及清除保护仍然被禁用。
我在 Key Vault 上有一个条件,将重新部署 Key Vault 实例设置为 false。考虑到这一点,我有两个问题:
- 是在参数上设置的条件,阻止 ARM 模板更新资源,如果是这样,如果我删除此条件,将不会重新部署 Key Vault 并可能删除任何已上传的密钥/机密/证书手动?
- 如果条件属性不是造成这种情况的原因,我是否还需要启用清除保护才能使更改生效?
【问题讨论】:
标签: azure azure-keyvault arm-template