New-AzResourceLock
语法
BySpecifiedScope (默认值)
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>]
说明
New-AzResourceLock cmdlet 创建资源锁。
示例
示例 1:在网站上创建资源锁
New-AzResourceLock -LockLevel CanNotDelete -LockNotes "My lock notes" -LockName "ContosoSiteLock" -ResourceName "ContosoSite" -ResourceType "microsoft.web/sites"
此命令在网站上创建资源锁。
示例 2:在数据库上创建资源锁
New-AzResourceLock -LockLevel CanNotDelete -LockNotes "Lock note" -LockName "db-lock" -ResourceName "server1/ContosoDB" -ResourceGroupName "RG1" -ResourceType "Microsoft.Sql/servers/databases"
此命令在 Azure 数据库上创建资源锁。
参数
-ApiVersion
指定要使用的资源提供程序 API 的版本。
如果未指定版本,此 cmdlet 将使用最新的可用版本。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DefaultProfile
用于与 azure 通信的凭据、帐户、租户和订阅
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Force
强制命令运行而不要求用户确认。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-LockId
指定锁的 ID。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | Id, ResourceId |
参数集
ByLockId
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-LockLevel
指定锁的级别。
目前,有效值为 CanNotDelete、ReadOnly。
参数属性
类型: | LockLevel
|
默认值: | None |
接受的值: | CanNotDelete, ReadOnly |
支持通配符: | False |
不显示: | False |
别名: | 级别 |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-LockName
指定锁的名称。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | ExtensionResourceName, 名称 |
参数集
BySpecifiedScope
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
ByResourceGroup
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
ByResourceGroupLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
BySubscription
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
BySubscriptionLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-LockNotes
指定锁的注释。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | 注释 |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Pre
指示此 cmdlet 在自动确定要使用的版本时会考虑预发布 API 版本。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ResourceGroupName
指定应用锁的资源组的名称,或包含锁适用的资源组的名称。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ByResourceGroup
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
ByResourceGroupLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-ResourceName
指定应用锁的资源的名称。
例如,若要指定数据库,请使用以下格式:ContosoServer/ContosoDatabase
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ByResourceGroupLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
BySubscriptionLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-ResourceType
指定应用锁的资源的资源类型。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ByResourceGroupLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
BySubscriptionLevel
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Scope
指定锁定应用到的范围。
例如,若要指定数据库,请使用以下格式:/subscriptions/
订阅 ID/resourceGroups/
资源组名称/providers/Microsoft.Sql/servers/
服务器名称/databases/
数据库名称指定资源组,请使用以下格式:/subscriptions/
订阅 ID/resourceGroups/
资源组名称
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
BySpecifiedScope
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。
命令脚本未运行。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输出