Linux command
az-lock 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create a read-only lock
az lock create --name [MyLock] --resource-group [MyResourceGroup] --lock-type ReadOnly
Create a delete lock
az lock create --name [MyLock] --resource-group [MyResourceGroup] --lock-type CanNotDelete
List all locks
az lock list --resource-group [MyResourceGroup]
Show details
az lock show --name [MyLock] --resource-group [MyResourceGroup]
Delete a lock
az lock delete --name [MyLock] --resource-group [MyResourceGroup]
Create a lock
az lock create --name [MyLock] --resource-group [MyResourceGroup] --resource-name [MyResource] --resource-type [Microsoft.Storage/storageAccounts] --lock-type CanNotDelete
说明
az lock manages Azure resource locks. Locks prevent accidental deletion or modification of critical resources. Two lock types are available: CanNotDelete allows read and modify operations but prevents deletion, while ReadOnly allows only read operations. Locks can be applied at subscription, resource group, or individual resource level. Child resources inherit locks from parent resources.
参数
- --name -n
- Name of the lock.
- --lock-type -t
- Type of lock: CanNotDelete or ReadOnly.
- --resource-group -g
- Name of resource group.
- --resource-name --resource
- Name of the resource being locked.
- --resource-type
- The type of the resource being locked (e.g., Microsoft.Network/subnets).
- --namespace
- Provider namespace (e.g., Microsoft.Provider).
- --parent
- Parent path for nested resources (e.g., resA/myA/resB/myB).
- --notes
- Notes about the lock.
- --ids
- One or more resource IDs. Used with delete/show/update instead of --name.
FAQ
What is the az-lock command used for?
az lock manages Azure resource locks. Locks prevent accidental deletion or modification of critical resources. Two lock types are available: CanNotDelete allows read and modify operations but prevents deletion, while ReadOnly allows only read operations. Locks can be applied at subscription, resource group, or individual resource level. Child resources inherit locks from parent resources.
How do I run a basic az-lock example?
Run `az lock create --name [MyLock] --resource-group [MyResourceGroup] --lock-type ReadOnly` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --name -n do in az-lock?
Name of the lock.