使用专用链接限制托管磁盘导入和导出

适用于: ✔️ Linux 虚拟机 ✔️ Windows 虚拟机 ✔️ 灵活规模集

使用 专用终结点 限制托管磁盘导入和导出。 通过Azure虚拟网络中的客户端专用链接安全地访问数据。 专用终结点为托管磁盘服务使用虚拟网络地址空间中的 IP 地址。 虚拟网络中的客户端与托管磁盘之间的流量会保留在虚拟网络以及 Microsoft 主干网络上的专用链路内,从而减少暴露于公共互联网的风险。

若要使用专用链接进行托管磁盘导入或导出,请创建磁盘访问资源,并通过创建专用终结点将其链接到同一订阅中的虚拟网络。 然后将磁盘或快照与磁盘访问资源相关联。 最后,将磁盘或快照的网络访问策略设置为 AllowPrivate 限制对虚拟网络的访问。

将网络访问策略设置为 DenyAll,以防止任何人从磁盘或快照中导出数据。 默认网络访问策略为 AllowAll

先决条件

在开始之前,请安装最新的Azure CLIAzure PowerShell模块

局限性

  • 不能使用相同的磁盘访问资源同时导入或导出 100 多个磁盘或快照
  • 不能将数据上传到同时具有磁盘访问资源和磁盘加密集的磁盘
  • 除了应用于单个磁盘的缩放目标外,磁盘访问资源还具有更多的缩放目标,这些目标以数据入口/出口为中心。 这些限制累积应用于与磁盘访问资源关联的所有磁盘。 有关详细信息,请参阅 此处
  • 磁盘访问资源必须与其关联的磁盘所在的区域和订阅相同。

登录并设置变量

选择一个选项卡以使用Azure CLI或Azure PowerShell。

subscriptionId=yourSubscriptionId
resourceGroupName=yourResourceGroupName
region=chinanorth2
diskAccessName=yourDiskAccessForPrivateLinks
vnetName=yourVNETForPrivateLinks
subnetName=yourSubnetForPrivateLinks
privateEndPointName=yourPrivateLinkForSecureMDExportImport
privateEndPointConnectionName=yourPrivateLinkConnection
privateDnsZoneName=privatelink.blob.core.chinacloudapi.cn
privateDnsZoneLinkName=yourDNSLink
privateDnsZoneGroupName=yourZoneGroup

# The name of an existing disk that is the source of the snapshot.
sourceDiskName=yourSourceDiskForSnapshot

# The name of the new snapshot secured with Private Links.
snapshotNameSecuredWithPL=yourSnapshotNameSecuredWithPL

az cloud set -n AzureChinaCloud
az login
az account set --subscription $subscriptionId

创建磁盘访问资源

az disk-access create -n $diskAccessName -g $resourceGroupName -l $region

diskAccessId=$(az disk-access show -n $diskAccessName -g $resourceGroupName --query [id] -o tsv)

创建虚拟网络

专用终结点不支持网络安全组(NSG)等网络策略。 若要在子网上部署专用终结点,请在该子网上禁用专用终结点网络策略。

az network vnet create --resource-group $resourceGroupName \
    --name $vnetName \
    --subnet-name $subnetName

az network vnet subnet update --resource-group $resourceGroupName \
    --name $subnetName \
    --vnet-name $vnetName \
    --private-endpoint-network-policies Disabled

为磁盘访问资源创建专用终结点

az network private-endpoint create --resource-group $resourceGroupName \
    --name $privateEndPointName \
    --vnet-name $vnetName \
    --subnet $subnetName \
    --private-connection-resource-id $diskAccessId \
    --group-ids disks \
    --connection-name $privateEndPointConnectionName

配置专用 DNS 区域

为存储 Blob 域创建专用 DNS 区域,创建虚拟网络链接,然后创建将专用终结点与专用 DNS 区域关联的 DNS 区域组。

az network private-dns zone create --resource-group $resourceGroupName \
    --name $privateDnsZoneName

az network private-dns link vnet create --resource-group $resourceGroupName \
    --zone-name $privateDnsZoneName \
    --name $privateDnsZoneLinkName \
    --virtual-network $vnetName \
    --registration-enabled false

az network private-endpoint dns-zone-group create \
   --resource-group $resourceGroupName \
   --endpoint-name $privateEndPointName \
   --name $privateDnsZoneGroupName \
   --private-dns-zone $privateDnsZoneName \
   --zone-name disks
# These variables are specific to this step.
diskName=yourDiskName
diskSkuName=Standard_LRS
diskSizeGB=128

diskAccessId=$(az resource show -n $diskAccessName -g $resourceGroupName --namespace Microsoft.Compute --resource-type diskAccesses --query [id] -o tsv)

az disk create -n $diskName \
    -g $resourceGroupName \
    -l $region \
    --size-gb $diskSizeGB \
    --sku $diskSkuName \
    --network-access-policy AllowPrivate \
    --disk-access $diskAccessId
# This step reuses variables defined in the first CLI sample.

diskId=$(az disk show -n $sourceDiskName -g $resourceGroupName --query [id] -o tsv)

diskAccessId=$(az resource show -n $diskAccessName -g $resourceGroupName --namespace Microsoft.Compute --resource-type diskAccesses --query [id] -o tsv)

az snapshot create -n $snapshotNameSecuredWithPL \
    -g $resourceGroupName \
    -l $region \
    --source $diskId \
    --network-access-policy AllowPrivate \
    --disk-access $diskAccessId

后续步骤