简体   繁体   中英

Resource Group Lock using ARM Template

您好,我尝试使用ARM模板将资源组锁定为天蓝色,但如果有人已经熟悉,请帮忙。

We can use template to lock resource group directly without creating storage account.

The next example applies a read-only lock to the resource group :

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

See more details about how to lock resource and resource group with template in this article .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM