Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

az resource lock

Manage Azure resource level locks.

Commands

Name Description Type Status
az resource lock create

Create a resource-level lock.

Core GA
az resource lock delete

Delete a resource-level lock.

Core GA
az resource lock list

List lock information in the resource-level.

Core GA
az resource lock show

Show the details of a resource-level lock.

Core GA
az resource lock update

Update a resource-level lock.

Core GA

az resource lock create

Create a resource-level lock.

az resource lock create --lock-type {CanNotDelete, ReadOnly}
 --name
 [--acquire-policy-token]
 [--change-reference]
 [--namespace]
 [--notes]
 [--parent]
 [--resource --resource-name]
 [--resource-group]
 [--resource-type]

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.

Property Value
Accepted values: CanNotDelete, ReadOnly
--name -n

Name of the lock.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--namespace

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

Property Value
Parameter group: Resource Id Arguments
--notes

Notes about this lock.

--parent

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

Property Value
Parameter group: Resource Id Arguments
--resource --resource-name

If an ID is given, other resource arguments should not be given.

Property Value
Parameter group: Resource Id Arguments
--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').

Property Value
Parameter group: Resource Id Arguments

az resource lock delete

Delete a resource-level lock.

az resource lock delete [--acquire-policy-token]
 [--change-reference]
 [--ids]
 [--name]
 [--namespace]
 [--parent]
 [--resource --resource-name]
 [--resource-group]
 [--resource-type]

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}

Delete a resource-level lock. (autogenerated)

az resource lock delete --ids /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Web/sites/{WebApp}

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--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').

Property Value
Parameter group: Resource Id Arguments
--parent

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

Property Value
Parameter group: Resource Id Arguments
--resource --resource-name

If an ID is given, other resource arguments should not be given.

Property Value
Parameter group: Resource Id Arguments
--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').

Property Value
Parameter group: Resource Id Arguments

az resource lock list

List lock information in the resource-level.

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

Examples

List out all locks on a vnet

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--filter-string

A query filter to use to restrict the results.

--namespace

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

Property Value
Parameter group: Resource Id Arguments
--parent

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

Property Value
Parameter group: Resource Id Arguments
--resource --resource-name

If an ID is given, other resource arguments should not be given.

Property Value
Parameter group: Resource Id Arguments
--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').

Property Value
Parameter group: Resource Id Arguments

az resource lock show

Show the details of a resource-level lock.

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

Examples

Show a resource level lock

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

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

Property Value
Parameter group: Resource Id Arguments
--parent

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

Property Value
Parameter group: Resource Id Arguments
--resource --resource-name

If an ID is given, other resource arguments should not be given.

Property Value
Parameter group: Resource Id Arguments
--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').

Property Value
Parameter group: Resource Id Arguments

az resource lock update

Update a resource-level lock.

az resource lock update [--acquire-policy-token]
 [--change-reference]
 [--ids]
 [--lock-type {CanNotDelete, ReadOnly}]
 [--name]
 [--namespace]
 [--notes]
 [--parent]
 [--resource --resource-name]
 [--resource-group]
 [--resource-type]

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

Update a resource-level lock. (autogenerated)

az resource lock update --lock-type CanNotDelete --name lockName --namespace Microsoft.Network --resource-group MyResourceGroup --resource-name myvnet --resource-type Microsoft.Network/virtualNetworks

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--acquire-policy-token

Acquiring an Azure Policy token automatically for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--change-reference

The related change reference ID for this resource operation.

Property Value
Parameter group: Global Policy Arguments
--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.

Property Value
Accepted values: CanNotDelete, ReadOnly
--name -n

Name of the lock.

--namespace

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

Property Value
Parameter group: Resource Id Arguments
--notes

Notes about this lock.

--parent

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

Property Value
Parameter group: Resource Id Arguments
--resource --resource-name

If an ID is given, other resource arguments should not be given.

Property Value
Parameter group: Resource Id Arguments
--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').

Property Value
Parameter group: Resource Id Arguments

Feedback

Was this page helpful?