可以在 SAN 级别启用对弹性 SAN 终结点的公共 Internet 访问。 为弹性 SAN 启用公用网络访问后,可以配置通过存储服务终结点对各个卷组的公共访问。 默认情况下,即使在 SAN 级别允许对各个卷组进行访问,也会拒绝公共访问。 必须显式配置卷组以允许来自特定 IP 地址范围和虚拟网络子网的访问。
可以在创建弹性 SAN 时启用公用网络访问,也可以使用 Azure PowerShell 模块或 Azure CLI 为现有 SAN 启用公用网络访问。
# Set the variable values.
# The name of the resource group where the Elastic San is deployed.
$RgName = "<ResourceGroupName>"
# The name of the Elastic SAN.
$EsanName = "<ElasticSanName>"
# The region where the new Elastic San will be created.
$Location = "<Location>"
# The SKU of the new Elastic SAN - `Premium_LRS` or `Premium_ZRS`.
$SkuName = "<SkuName>"
# The base size of the new Elastic SAN.
$BaseSize = "<BaseSize>"
# The extended size of the new Elastic SAN.
$ExtendedSize = "<ExtendedSize>"
# Setup the parameters to create an Elastic San with public network access enabled.
$NewEsanArguments = @{
Name = $EsanName
ResourceGroupName = $RgName
BaseSizeTiB = $BaseSize
ExtendedCapacitySizeTiB = $ExtendedSize
Location = $Location
SkuName = $SkuName
PublicNetworkAccess = "Enabled"
}
# Create the Elastic San.
New-AzElasticSan @NewEsanArguments
# Set the variable values.
# The name of the resource group where the Elastic San is deployed.
$RgName="<ResourceGroupName>"
# The name of the Elastic SAN.
$EsanName="<ElasticSanName>"
# The region where the new Elastic San will be created.
$Location="<Location>"
# The SKU of the new Elastic SAN - `Premium_LRS` or `Premium_ZRS`.
$SkuName="<SkuName>"
# The base size of the new Elastic SAN.
$BaseSize="<BaseSize>"
# The extended size of the new Elastic SAN.
$ExtendedSize="<ExtendedSize>"
# Create the Elastic San.
az elastic-san create \
--elastic-san-name $EsanName \
--resource-group $RgName \
--location $Location \
--base-size-tib $BaseSize \
--extended-capacity-size-tib $ExtendedSize \
--sku $SkuName \
--public-network-access enabled
# Set the variable values.
$RgName="<ResourceGroupName>"
$EsanName="<ElasticSanName>"
# Update the Elastic San.
az elastic-san update \
--elastic-san-name $EsanName \
--resource-group $RgName \
--public-network-access enabled
配置 iSCSI 错误检测
启用 iSCSI 错误检测
若要为 iSCSI 标头或数据有效负载启用 CRC-32C 校验和验证,请在连接到弹性 SAN 卷的客户端上为所有连接的标头或数据摘要设置 CRC-32C。 为此,可以使用 Azure 门户中生成的多会话脚本,或者使用 Windows 或 Linux 弹性 SAN 连接文章中提供的脚本,将客户端连接到弹性 SAN 卷。
如果需要,也可以在不使用多会话连接脚本的情况下进行连接。 在 Windows 上,可以在登录到弹性 SAN 卷(LoginTarget 和 PersistentLoginTarget)时通过将标头或数据摘要设置为 1 来实现。 在 Linux 上,可以通过更新全局 iSCSI 配置文件(iscsid.conf,通常位于 /etc/iscsi 目录中)来实现。 连接卷后,将创建一个节点以及特定于此节点的配置文件(例如,在 Ubuntu 上,可以位于 /etc/iscsi/nodes/$volume_iqn/portal_hostname,$port 目录中),该文件从全局配置文件继承设置。 如果在更新全局配置文件之前已将卷连接到客户端,请直接或使用以下命令更新每个卷的节点特定配置文件:
若要强制实施 iSCSI 错误检测,请在客户端上为标头和数据摘要设置 CRC-32C,并在包含已连接到或尚未连接到客户端的卷的卷组中启用 CRC 保护属性。 如果弹性 SAN 卷已连接,并且两个摘要都没有 CRC-32C,则应断开卷的连接,并使用连接到弹性 SAN 卷时在 Azure 门户中生成的多会话脚本重新连接卷,或者使用 Windows 或 Linux 弹性 SAN 连接文章中提供的脚本重新连接卷。
# Set the variable values.
# The name of the resource group where the Elastic San is deployed.
$RgName = "<ResourceGroupName>"
# The name of the Elastic SAN.
$EsanName = "<ElasticSanName>"
# The name of volume group within the Elastic SAN.
$EsanVgName = "<VolumeGroupName>"
# Create a volume group by enabling CRC protection
New-AzElasticSanVolumeGroup -ResourceGroupName $RgName -ElasticSANName $EsanName -Name $EsanVgName -EnforceDataIntegrityCheckForIscsi $true
# Set the variable values.
# The name of the resource group where the Elastic San is deployed.
RgName="<ResourceGroupName>"
# The name of the Elastic SAN.
EsanName="<ElasticSanName>"
# The name of volume group within the Elastic SAN.
EsanVgName= "<VolumeGroupName>"
# Create the Elastic San.
az elastic-san volume-group create \
--elastic-san-name $EsanName \
--resource-group $RgName \
--volume-group-name $EsanVgName \
--data-integrity-check true
要为弹性 SAN 卷组创建专用终结点,必须具有弹性 SAN 卷组所有者角色。 若要批准新的专用终结点连接,必须对 Azure 资源提供程序操作Microsoft.ElasticSan/elasticSans/PrivateEndpointConnectionsApproval/action具有权限。 此操作的权限包含在弹性 SAN 网络管理员角色中,但也可以通过自定义 Azure 角色授予。
使用此示例代码可以使用 PowerShell 为弹性 SAN 卷组创建专用终结点。 将 RgName、VnetName、SubnetName、EsanName、EsanVgName、PLSvcConnectionName、EndpointName 和 Location(区域)的值替换为自己的值:
# Set the resource group name.
$RgName = "<ResourceGroupName>"
# Set the virtual network and subnet, which is used when creating the private endpoint.
$VnetName = "<VnetName>"
$SubnetName = "<SubnetName>"
$Vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $RgName
$Subnet = $Vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq $SubnetName}
# Set the Elastic SAN, which is used when creating the private endpoint service connection.
$EsanName = "<ElasticSanName>"
$EsanVgName = "<ElasticSanVolumeGroupName>"
$Esan = Get-AzElasticSan -Name $EsanName -ResourceGroupName $RgName
# Create the private link service connection, which is input to creating the private endpoint.
$PLSvcConnectionName = "<PrivateLinkSvcConnectionName>"
$EsanPlSvcConn = New-AzPrivateLinkServiceConnection -Name $PLSvcConnectionName -PrivateLinkServiceId $Esan.Id -GroupId $EsanVgName
# Create the private endpoint.
$EndpointName = '<PrivateEndpointName>'
$Location = '<Location>'
$PeArguments = @{
Name = $EndpointName
ResourceGroupName = $RgName
Location = $Location
Subnet = $Subnet
PrivateLinkServiceConnection = $EsanPlSvcConn
}
New-AzPrivateEndpoint @PeArguments # -ByManualRequest # (Uncomment the `-ByManualRequest` parameter if you are using the two-step process).
如果使用两步流程,请使用此示例代码批准专用链接服务连接。 使用上一个代码示例中的相同变量:
# Get the private endpoint and associated connection.
$PrivateEndpoint = Get-AzPrivateEndpoint -Name $EndpointName -ResourceGroupName $RgName
$PeConnArguments = @{
ServiceName = $EsanName
ResourceGroupName = $RgName
PrivateLinkResourceType = "Microsoft.ElasticSan/elasticSans"
}
$EndpointConnection = Get-AzPrivateEndpointConnection @PeConnArguments |
Where-Object {($_.PrivateEndpoint.Id -eq $PrivateEndpoint.Id)}
# Approve the private link service connection.
$ApprovalDesc="<ApprovalDesc>"
Approve-AzPrivateEndpointConnection @PeConnArguments -Name $EndpointConnection.Name -Description $ApprovalDesc
# Get the private endpoint connection anew and verify the connection status.
$EndpointConnection = Get-AzPrivateEndpointConnection @PeConnArguments |
Where-Object {($_.PrivateEndpoint.Id -eq $PrivateEndpoint.Id)}
$EndpointConnection.PrivateLinkServiceConnectionState
使用 Azure CLI 为弹性 SAN 卷组部署专用终结点包括三个步骤:
获取弹性 SAN 的专用连接资源 ID。
使用输入创建专用终结点:
专用连接资源 ID
卷组名称
资源组名称
子网名称
虚拟网络名称
(可选)如果使用两步流程(创建,然后批准):弹性 SAN 网络管理员批准连接。
使用此示例代码可以使用 Azure CLI 为弹性 SAN 卷组创建专用终结点。 如果使用两步过程,则取消注释 --manual-request 参数。 将所有示例变量值替换为你自己的值:
# Define some variables.
# The name of the resource group where the resources are deployed.
RgName="<ResourceGroupName>"
# The name of the subnet from which access to the volume group will be configured.
VnetName="<VnetName>"
# The name of the virtual network that includes the subnet.
SubnetName="<SubnetName>"
# The name of the Elastic SAN that the volume group belongs to.
EsanName="<ElasticSanName>"
# The name of the Elastic SAN Volume Group to which a connection is to be created.
EsanVgName="<ElasticSanVolumeGroupName>"
# The name of the new private endpoint
EndpointName="<PrivateEndpointName>"
# The name of the new private link service connection to the volume group.
PLSvcConnectionName="<PrivateLinkSvcConnectionName>"
# The region where the new private endpoint will be created.
Location="<Location>"
# The description provided for the approval of the private endpoint connection.
ApprovalDesc="<ApprovalDesc>"
# Get the id of the Elastic SAN.
id=$(az elastic-san show \
--elastic-san-name $EsanName \
--resource-group $RgName \
--query 'id' \
--output tsv)
# Create the private endpoint.
az network private-endpoint create \
--connection-name $PLSvcConnectionName \
--name $EndpointName \
--private-connection-resource-id $id \
--resource-group $RgName \
--vnet-name $VnetName \
--subnet $SubnetName \
--location $Location \
--group-id $EsanVgName # --manual-request
# Verify the status of the private endpoint connection.
PLConnectionName=$(az network private-endpoint-connection list \
--name $EsanName \
--resource-group $RgName \
--type Microsoft.ElasticSan/elasticSans \
--query "[?properties.groupIds[0]=='$EsanVgName'].name" -o tsv)
az network private-endpoint-connection show \
--resource-name $EsanName \
--resource-group $RgName \
--type Microsoft.ElasticSan/elasticSans \
--name $PLConnectionName
若要为属于另一个 Microsoft Entra 租户的虚拟网络中的子网添加网络规则,请使用完全限定的“VirtualNetworkResourceId”参数,并采用“/subscriptions/subscription-ID/resourceGroups/resourceGroup-Name/providers/Microsoft.Network/virtualNetworks/vNet-name/subnets/subnet-name”格式。
删除虚拟网络规则。
## You can remove a virtual network rule by object, by resource ID, or by removing all the rules in a volume group
### remove by networkRule object
Remove-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myRGName -ElasticSanName mySANName -VolumeGroupName myVolGroupName -NetworkAclsVirtualNetworkRule $virtualNetworkRule1,$virtualNetworkRule2
### remove by networkRuleResourceId
Remove-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myRGName -ElasticSanName mySANName -VolumeGroupName myVolGroupName -NetworkAclsVirtualNetworkResourceId "myResourceID"
### Remove all network rules in a volume group by pipeline
((Get-AzElasticSanVolumeGroup -ResourceGroupName myRGName -ElasticSanName mySANName -VolumeGroupName myVolGroupName).NetworkAclsVirtualNetworkRule) | Remove-AzElasticSanVolumeGroupNetworkRule -ResourceGroupName myRGName -ElasticSanName mySANName -VolumeGroupName myVolGroupName
若要为属于另一个 Microsoft Entra 租户的虚拟网络中的子网添加规则,请使用完全限定的子网 ID,格式为 /subscriptions/\<subscription-ID\>/resourceGroups/\<resourceGroup-Name\>/providers/Microsoft.Network/virtualNetworks/\<vNet-name\>/subnets/\<subnet-name\>。
可以使用“subscription”参数检索属于另一个 Microsoft Entra 租户的虚拟网络的子网 ID。
# First, get the current length of the list of virtual networks. This is needed to ensure you append a new network instead of replacing existing ones.
virtualNetworkListLength = az elastic-san volume-group show -e $sanName -n $volumeGroupName -g $RgName --query 'length(networkAcls.virtualNetworkRules)'
az elastic-san volume-group update -e $sanName -g $RgName --name $volumeGroupName --network-acls virtual-network-rules[$virtualNetworkListLength] "{virtualNetworkRules:[{id:/subscriptions/subscriptionID/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/default, action:Allow}]}"