【发布时间】:2021-11-02 09:27:26
【问题描述】:
我正在尝试编写一个 Azure 策略来检查 Azure 密钥是否有到期日期,如果没有,那么我想做一个 DeployIfNotExists 效果来设置一个。但是我收到“ResourceNotFound”错误。
注意:没有“then”语句的“if”语句可以正常工作,当我运行此策略时,它会显示哪些密钥没有到期日期。添加 deployifnotexist 效果时出现问题。
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault/vaults/keys"
},
{
"field": "Microsoft.KeyVault/vaults/keys/attributes.exp",
"exists": false
}
]
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.KeyVault/vaults/keys",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.KeyVault/vaults/keys",
"apiVersion": "2021-06-01-preview",
"properties": {
"exp": "10000"
}
}
]
}
}
}
}
}
},
"parameters": {}
}
【问题讨论】:
标签: azure azure-policy