az lock
Manage Azure locks.
Commands
az lock create |
Create a lock. |
az lock delete |
Delete a lock. |
az lock list |
List lock information. |
az lock show |
Show the properties of a lock. |
az lock update |
Update a lock. |
az lock create
Create a lock.
Locks can exist at three different scopes: subscription, resource group and resource.
az lock create --lock-type {CanNotDelete, ReadOnly}
--name
[--namespace]
[--notes]
[--parent]
[--resource]
[--resource-group]
[--resource-type]
[--subscription]
Examples
Create a read-only subscription level lock.
az lock create --name lockName --resource-group group --lock-type ReadOnly
Create a read-only resource level lock on a vnet resource.
az lock create --name lockName --resource-group group --lock-type ReadOnly --resource-type \
Microsoft.Network/virtualNetworks --resource myVnet
Create a read-only resource level lock on a subnet resource with a specific parent.
az lock create --name lockName --resource-group group --lock-type ReadOnly --resource-type \
Microsoft.Network/subnets --parent virtualNetworks/myVnet --resource mySubnet
Required Parameters
The type of lock restriction.
Name of the lock.
Optional Parameters
Provider namespace (Ex: 'Microsoft.Provider').
Notes about this lock.
The parent path (Ex: 'resA/myA/resB/myB').
Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
az lock delete
Delete a lock.
az lock delete [--ids]
[--name]
[--namespace]
[--parent]
[--resource]
[--resource-group]
[--resource-type]
[--subscription]
Examples
Delete a resource group-level lock
az lock delete --name lockName --resource-group group
Optional Parameters
One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.
Name of the lock.
Provider namespace (Ex: 'Microsoft.Provider').
The parent path (Ex: 'resA/myA/resB/myB').
Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
az lock list
List lock information.
az lock list [--filter-string]
[--namespace]
[--parent]
[--query-examples]
[--resource]
[--resource-group]
[--resource-type]
[--subscription]
Examples
List out the locks on a vnet resource. Includes locks in the associated group and subscription.
az lock list --resource myvnet --resource-type Microsoft.Network/virtualNetworks -g group
List out all locks on the subscription level
az lock list
Optional Parameters
A query filter to use to restrict the results.
Provider namespace (Ex: 'Microsoft.Provider').
The parent path (Ex: 'resA/myA/resB/myB').
Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.
Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
az lock show
Show the properties of a lock.
az lock show [--ids]
[--name]
[--namespace]
[--parent]
[--query-examples]
[--resource]
[--resource-group]
[--resource-type]
[--subscription]
Examples
Show a subscription level lock
az lock show -n lockname
Show the properties of a lock (autogenerated)
az lock show --name lockname --resource-group MyResourceGroup --resource-name MyResource --resource-type Microsoft.Network/virtualNetworks
Optional Parameters
One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.
Name of the lock.
Provider namespace (Ex: 'Microsoft.Provider').
The parent path (Ex: 'resA/myA/resB/myB').
Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.
Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
az lock update
Update a lock.
az lock update [--ids]
[--lock-type {CanNotDelete, ReadOnly}]
[--name]
[--namespace]
[--notes]
[--parent]
[--resource]
[--resource-group]
[--resource-type]
[--subscription]
Examples
Update a resource group level lock with new notes and type
az lock update --name lockName --resource-group group --notes newNotesHere --lock-type CanNotDelete
Optional Parameters
One or more resource IDs (space-delimited). If provided, no other "Resource Id" arguments should be specified.
The type of lock restriction.
Name of the lock.
Provider namespace (Ex: 'Microsoft.Provider').
Notes about this lock.
The parent path (Ex: 'resA/myA/resB/myB').
Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.