你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Remove-AzElasticSanVolumeGroupNetworkRule

从 VolumeGroup 中删除虚拟网络规则列表

语法

Remove-AzElasticSanVolumeGroupNetworkRule
      -ElasticSanName <String>
      -VolumeGroupName <String>
      -ResourceGroupName <String>
      [-SubscriptionId <String>]
      -NetworkAclsVirtualNetworkRule <IVirtualNetworkRule[]>
      [-DefaultProfile <PSObject>]
      [-AsJob]
      [-NoWait]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzElasticSanVolumeGroupNetworkRule
      -ElasticSanName <String>
      -VolumeGroupName <String>
      -ResourceGroupName <String>
      [-SubscriptionId <String>]
      -NetworkAclsVirtualNetworkResourceId <String[]>
      [-DefaultProfile <PSObject>]
      [-AsJob]
      [-NoWait]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

说明

从 VolumeGroup 中删除虚拟网络规则列表

示例

示例 1:通过 NetworkAclsVirtualNetworkRule 对象删除网络规则

# Initialze network rule objects 
$virtualNetworkRule1 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet1" -Action Allow
$virtualNetworkRule2 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet2" -Action Allow
$virtualNetworkRule3 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet3" -Action Allow
# Add the network rule objects to the volume group
$rules = Add-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myresourcegroup -ElasticSanName myelasticsan -VolumeGroupName myvolumegroup -NetworkAclsVirtualNetworkRule $virtualNetworkRule1,$virtualNetworkRule2,$virtualNetworkRule3

# Remove some of the network rules from the volume group
Remove-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myresourcegroup -ElasticSanName myelasticsan -VolumeGroupName myvolumegroup -NetworkAclsVirtualNetworkRule $virtualNetworkRule1,$virtualNetworkRule2

Action State VirtualNetworkResourceId                                                                                                                       
------ ----- ------------------------                                                                                                                       
Allow        /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet3

本示例向卷组添加 3 个网络规则,然后通过输入网络规则对象从卷组中删除 2 个网络规则。 该命令将输出删除后卷组中保留的所有网络规则对象。

示例 2:按网络规则资源 ID 删除网络规则

$virtualNetworkRule1 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet1" -Action Allow
$virtualNetworkRule2 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet2" -Action Allow
$virtualNetworkRule3 =  New-AzElasticSanVirtualNetworkRuleObject -VirtualNetworkResourceId  "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet3" -Action Allow
$virtualNetworkRuleResourceId1 = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet1"
$virtualNetworkRuleResourceId2 = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet2"
# Update the volume group to contain the network rules 
$volGroup = Update-AzElasticSanVolumeGroup -ResourceGroupName myresourcegroup -ElasticSanName myelasticsan -Name myvolumegroup -NetworkAclsVirtualNetworkRule $virtualNetworkRule1,$virtualNetworkRule2,$virtualNetworkRule3

# Remove some of the network rules from the volume group
Remove-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myresourcegroup -ElasticSanName myelasticsan -VolumeGroupName myvolumegroup -NetworkAclsVirtualNetworkResourceId $virtualNetworkRuleResourceId1,$virtualNetworkRuleResourceId2

Action State VirtualNetworkResourceId                                                                                                                       
------ ----- ------------------------                                                                                                                       
Allow        /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/subnet3

本示例向卷组添加 3 个网络规则,然后通过输入网络规则资源 ID 从卷组中删除 2 个网络规则。 该命令将输出删除后卷组中保留的所有网络规则对象。

参数

-AsJob

以作业身份运行命令

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:PSObject
别名:AzureRMContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-ElasticSanName

ElasticSan 的名称。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-NetworkAclsVirtualNetworkResourceId

虚拟网络规则资源 ID 的列表。 若要构造,请参阅 NETWORKACLSVIRTUALNETWORKRULE 属性的 NOTES 部分,并创建哈希表。

类型:String[]
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-NetworkAclsVirtualNetworkRule

虚拟网络规则的列表。 若要构造,请参阅 NETWORKACLSVIRTUALNETWORKRULE 属性的 NOTES 部分,并创建哈希表。

类型:IVirtualNetworkRule[]
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-NoWait

异步运行命令

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-ResourceGroupName

资源组的名称。 此名称不区分大小写。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-SubscriptionId

目标订阅的 ID。

类型:String
Position:Named
默认值:(Get-AzContext).Subscription.Id
必需:False
接受管道输入:False
接受通配符:False

-VolumeGroupName

VolumeGroup 的名称。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

输入

IVirtualNetworkRule[]

输出

VirtualNetworkRule[]