New-AzResourceLock
Syntax
BySpecifiedScope (Default)
New-AzResourceLock
-LockName <String>
-LockLevel <LockLevel>
-Scope <String>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByResourceGroup
New-AzResourceLock
-LockName <String>
-LockLevel <LockLevel>
-ResourceGroupName <String>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByResourceGroupLevel
New-AzResourceLock
-LockName <String>
-LockLevel <LockLevel>
-ResourceName <String>
-ResourceType <String>
-ResourceGroupName <String>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
BySubscription
New-AzResourceLock
-LockName <String>
-LockLevel <LockLevel>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
BySubscriptionLevel
New-AzResourceLock
-LockName <String>
-LockLevel <LockLevel>
-ResourceName <String>
-ResourceType <String>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByLockId
New-AzResourceLock
-LockLevel <LockLevel>
-LockId <String>
[-LockNotes <String>]
[-Force]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-AzResourceLock cmdlet creates a resource lock.
Examples
Example 1: Create a resource lock on a website
New-AzResourceLock -LockLevel CanNotDelete -LockNotes "My lock notes" -LockName "ContosoSiteLock" -ResourceName "ContosoSite" -ResourceType "microsoft.web/sites"
This command creates a resource lock on a website.
Example 2: Create a resource lock on a database
New-AzResourceLock -LockLevel CanNotDelete -LockNotes "Lock note" -LockName "db-lock" -ResourceName "server1/ContosoDB" -ResourceGroupName "RG1" -ResourceType "Microsoft.Sql/servers/databases"
This command creates a resource lock on an Azure database.
Parameters
-ApiVersion
Specifies the version of the resource provider API to use.
If you do not specify a version, this cmdlet uses the latest available version.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Force
Forces the command to run without asking for user confirmation.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-LockId
Specifies the ID of the lock.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Id, ResourceId
Parameter sets
ByLockId
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-LockLevel
Specifies the level for the lock.
Currently, valid values are CanNotDelete, ReadOnly.
Parameter properties
Type: LockLevel
Default value: None
Accepted values: CanNotDelete, ReadOnly
Supports wildcards: False
DontShow: False
Aliases: Level
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-LockName
Specifies the name of the lock.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ExtensionResourceName, Name
Parameter sets
BySpecifiedScope
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByResourceGroup
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByResourceGroupLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
BySubscription
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
BySubscriptionLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-LockNotes
Specifies the notes for the lock.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Notes
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Pre
Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
Specifies the name of a resource group for which the lock applies or that contains the resource group for which the lock applies.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceGroup
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByResourceGroupLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceName
Specifies the name of the resource for which the lock applies.
For instance, to specify a database, use the following format:
ContosoServer/ContosoDatabase
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceGroupLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
BySubscriptionLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceType
Specifies the resource type of the resource for which the lock applies.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceGroupLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
BySubscriptionLevel
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Scope
Specifies the scope to which the lock applies.
For instance, to specify a database, use the following format:
/subscriptions/
subscription ID/resourceGroups/
resource group name/providers/Microsoft.Sql/servers/
server name/databases/
database name
To specify a resource group, use the following format:
/subscriptions/
subscription ID/resourceGroups/
resource group name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BySpecifiedScope
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs