嗨我试图使用ARM模板在azure中锁定资源组,但我无法这样做,如果有人已经熟悉,请帮助我。
答案 0 :(得分:5)
我们可以直接使用模板锁定资源组,而无需创建存储帐户。
下一个示例将只读锁应用于资源组:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Authorization/locks",
"apiVersion": "2015-01-01",
"name": "MyGroupLock",
"properties":
{
"level": "ReadOnly",
"notes": "my notes"
}
}
],
"outputs": {}
}
有关如何使用this article中的模板锁定资源和资源组的详细信息。
答案 1 :(得分:2)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"lockedResource": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('lockedResource'), '/Microsoft.Authorization/myLock')]",
"type": "Microsoft.Storage/storageAccounts/providers/locks",
"apiVersion": "2015-01-01",
"properties": {
"level": "CannotDelete"
}
}
]
}
https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-lock-resources#template