PowerShell を使って、公衆ネットワーク アクセスが有効な Elastic 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
PowerShell を使い、Elastic SAN を更新して公衆ネットワーク アクセスを有効にするには、次のサンプル コードを使います。 RgName と EsanName の値を独自の値に置き換えてから、サンプルを実行します。
# Set the variable values.
$RgName = "<ResourceGroupName>"
$EsanName = "<ElasticSanName>"
# Update the Elastic San.
Update-AzElasticSan -Name $EsanName -ResourceGroupName $RgName -PublicNetworkAccess Enabled
Azure CLI を使って、公衆ネットワーク アクセスが有効な Elastic 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>"
# 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.
# 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
# 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).
# 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 テナントの一部である仮想ネットワーク内のサブネットへのアクセスを許可するルールの構成は、現在、PowerShell、CLI、REST API でのみサポートされています。 これらの規則は、Azure portal を使って構成することはできませんが、ポータルで表示することはできます。
別の Microsoft Entra テナントに属する仮想ネットワーク内のサブネットに対するネットワーク規則を追加するには、"/subscriptions/<サブスクリプション ID>/resourceGroups/<リソース グループ名>/providers/Microsoft.Network/virtualNetworks/<仮想ネットワーク名>/subnets/<サブネット名>" という形式で完全修飾された VirtualNetworkResourceId パラメーターを使います。
仮想ネットワーク規則を削除します。
## 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 テナントに属する仮想ネットワーク内のサブネット用に規則を追加するには、/subscriptions/\<subscription-ID\>/resourceGroups/\<resourceGroup-Name\>/providers/Microsoft.Network/virtualNetworks/\<vNet-name\>/subnets/\<subnet-name\> という形式の完全修飾サブネット ID を使います。
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}]}"