az resource lock

Manage Azure resource level locks.

Commands

az resource lock create Create a resource-level lock.
az resource lock delete Delete a resource-level lock.
az resource lock list List lock information in the resource-level.
az resource lock show Show the details of a resource-level lock.
az resource lock update Update a resource-level lock.

az resource lock create

Create a resource-level lock.

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

Examples

Create a read-only resource level lock on a vnet.

az resource lock create --lock-type ReadOnly -n lockName -g MyResourceGroup --resource myvnet --resource-type Microsoft.Network/virtualNetworks

Create a read-only resource level lock on a vnet using a vnet id.

az resource lock create --lock-type ReadOnly -n lockName --resource /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}

Required Parameters

--lock-type -t

The type of lock restriction.

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

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').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az resource lock delete

Delete a resource-level lock.

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

Examples

Delete a resource level lock

az resource lock delete --name lockName -g MyResourceGroup --resource myvnet --resource-type Microsoft.Network/virtualNetworks

Delete a resource level lock on a vnet using a vnet id.

az resource lock delete -n lockName --resource /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VMName}

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

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').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az resource lock list

List lock information in the resource-level.

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

Examples

List out all locks on a vnet

az resource lock list -g MyResourceGroup --resource myvnet --resource-type Microsoft.Network/virtualNetworks

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

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').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az resource lock show

Show the details of a resource-level lock.

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

Examples

Show a resource level lock

az resource lock show -n lockname -g MyResourceGroup --resource myvnet --resource-type Microsoft.Network/virtualNetworks

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

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').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az resource lock update

Update a resource-level lock.

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

Examples

Update a resource level lock with new notes and type

az resource lock update --name lockName -g MyResourceGroup --resource myvnet --resource-type Microsoft.Network/virtualNetworks --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

The type of lock restriction.

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

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').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.