1

嗨,我尝试使用 ARM 模板将资源组锁定在 azure 中,但我无法这样做,如果有人已经熟悉,请帮助我。

4

2 回答 2

6

我们可以使用模板直接锁定资源组,而无需创建存储帐户。

下一个示例将只读锁应用于资源组

{
    "$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": {}
}

请参阅本文中有关如何使用模板锁定资源和资源组的更多详细信息。

于 2017-09-28T08:43:24.903 回答
3
{
  "$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

于 2017-09-28T08:16:14.140 回答