LinuxCommandLibrary

az-lock

Manage Azure resource locks

TLDR

Create a read-only lock on a resource group

$ az lock create --name [MyLock] --resource-group [MyResourceGroup] --lock-type ReadOnly
copy
Create a delete lock to prevent accidental deletion
$ az lock create --name [MyLock] --resource-group [MyResourceGroup] --lock-type CanNotDelete
copy
List all locks in a resource group
$ az lock list --resource-group [MyResourceGroup]
copy
Show details of a lock
$ az lock show --name [MyLock] --resource-group [MyResourceGroup]
copy
Delete a lock
$ az lock delete --name [MyLock] --resource-group [MyResourceGroup]
copy
Create a lock on a specific resource
$ az lock create --name [MyLock] --resource-group [MyResourceGroup] --resource-name [MyResource] --resource-type [Microsoft.Storage/storageAccounts] --lock-type CanNotDelete
copy

SYNOPSIS

az lock subcommand [options]

DESCRIPTION

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.

PARAMETERS

--name -n

Name of the lock.
--lock-type -t
Type of lock: CanNotDelete or ReadOnly.
--resource-group -g
Name of resource group.
--resource-name
Name of the resource being locked.
--resource-type
The type of the resource being locked.
--notes
Notes about the lock.

SUBCOMMANDS

create

Create a lock.
delete
Delete a lock.
list
List locks.
show
Show details of a lock.
update
Update a lock.

CAVEATS

Requires Azure CLI and appropriate RBAC permissions (Owner or User Access Administrator). Locks do not restrict actions performed by the Azure platform itself. A ReadOnly lock on a resource group affects all resources within it.

SEE ALSO

az(1), az-tag(1), az-provider(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community