Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzResourceLock
- Module:
- Az.Resources Module
Creates a resource lock.
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
-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
-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
-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
-LockId
Specifies the ID of the lock.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Id, ResourceId |
Parameter sets
-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
-LockName
Specifies the name of the lock.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ExtensionResourceName, Name |
Parameter sets
-LockNotes
Specifies the notes for the lock.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Notes |
Parameter sets
-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
-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
-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
-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
-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
-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
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.
Inputs
String
LockLevel
Outputs
PSObject
Related Links
Azure PowerShell
Feedback
Was this page helpful?
