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]

Examples

Create a read-only subscription level lock.

az lock create --name lockName --resource-group group --lock-type ReadOnly

Required Parameters

--lock-type -t
accepted values: CanNotDelete, ReadOnly
--name -n

Name of the lock.

Optional Parameters

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--notes

Notes about this lock.

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource --resource-name

Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az lock delete

Delete a lock.

az lock delete [--ids]
[--name]
[--namespace]
[--parent]
[--resource]
[--resource-group]
[--resource-type]

Examples

Delete a resource group-level lock

az lock delete --name lockName --resource-group group

Optional Parameters

--ids

One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.

--name -n

Name of the lock.

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource --resource-name

Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az lock list

List lock information.

az lock list [--filter-string]
[--namespace]
[--parent]
[--resource]
[--resource-group]
[--resource-type]

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

--filter-string

A query filter to use to restrict the results.

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource --resource-name

Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az lock show

Show the properties of a lock.

az lock show [--ids]
[--name]
[--namespace]
[--parent]
[--resource]
[--resource-group]
[--resource-type]

Examples

Show a subscription level lock

az lock show -n lockname

Optional Parameters

--ids

One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.

--name -n

Name of the lock.

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource --resource-name

Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').

az lock update

Update a lock.

az lock update [--ids]
[--lock-type {CanNotDelete, ReadOnly}]
[--name]
[--namespace]
[--notes]
[--parent]
[--resource]
[--resource-group]
[--resource-type]

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

--ids

One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.

--lock-type -t
accepted values: CanNotDelete, ReadOnly
--name -n

Name of the lock.

--namespace

Provider namespace (Ex: 'Microsoft.Provider').

--notes

Notes about this lock.

--parent

The parent path (Ex: 'resA/myA/resB/myB').

--resource --resource-name

Name or ID of the resource being locked. If an ID is given, other resource arguments should not be given.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-type

The resource type (Ex: 'resC'). Can also accept namespace/type format (Ex: 'Microsoft.Provider/resC').