官术网_书友最值得收藏!

  • Learn Azure Administration
  • Kamil Mrzyg?ód
  • 355字
  • 2021-06-11 18:14:31

Subscription locks

Each lock is a separate resource and is available on either a subscription, resource group, or a resource level. In this section, we will cover working with them using Azure portal, but under the hood, locks are just Azure resources that are accessible via the ARM API. If you want to create a lock, follow these steps:

  1. If you go to your subscription, you can find the Resource locks blade in the Settings section:
Figure 2.10: Resource locks blade
  1. From the new screen, you can click on the + Add button, where you will able to enter the lock's properties:
Figure 2.11: Creating a lock form

Adding a lock requires that you provide the following information:

    • Lock name: The unique lock name across the given scope
    • Lock type: Determines the behavior of a lock
    • Notes: Optional notes

Once you click the OK button, a lock will be applied on the subscription level and a specific action (changes/deletion) will become forbidden.

  1. The same can be done from the Azure CLI level. To list all the locks, you can use the following command:
$ az lock list
  1. Since we are using an Azure CLI command without providing an output type, the default result representation is a JSON document. It contains information about the full identifier of the lock (id), its type (the level parameter) and additional information (such as a description and its name):

[
{
"id": "/subscriptions/.../providers/Microsoft.Authorization/locks/Delete",
"level": "CanNotDelete",
"name": "Delete",
"notes": "Delete lock for the subscription",
"owners": null,
"type": "Microsoft.Authorization/locks"
}
]
  1. Now, to create a new one, execute the following command:
$ az lock create -n "Read-only" -t "ReadOnly"

Now, you should be able to see the result of creating a read-only lock. Since we only provided the name (-n) and lock type (-t), only those fields will be filled in inside the JSON document:

{
"id": "/subscriptions/.../providers/Microsoft.Authorization/locks/Read-only",
"level": "ReadOnly",
"name": "Read-only",
"notes": null,
"owners": null,
"type": "Microsoft.Authorization/locks"
}

Now, let's look at resource group locks, which are more focused locks. This is because they're only applied at the resource group level.

主站蜘蛛池模板: 武义县| 奉贤区| 武宣县| 沂南县| 万山特区| 田阳县| 双鸭山市| 随州市| 隆子县| 阳泉市| 京山县| 峨眉山市| 鹤岗市| 黄浦区| 彭泽县| 斗六市| 呼和浩特市| 乐都县| 蕲春县| 西城区| 汤原县| 尖扎县| 胶南市| 疏勒县| 旬邑县| 绥滨县| 绥德县| 鄂托克旗| 阿合奇县| 大同市| 德州市| 郑州市| 泸西县| 财经| 富锦市| 青浦区| 阜平县| 思茅市| 日土县| 镇远县| 彭州市|