$resourceGroupName = "<my-resource-group>"
$storageAccountName = "<my-storage-account-name>"
$region = "<my-region>"
# Valid SKUs are StandardV2_LRS (HDD Local provisioned v2), StandardV2_ZRS (HDD
# Zone provisioned v2), StandardV2_GRS (HDD Geo provisioned v2),
# StandardV2_GZRS (HDD GeoZone provisioned v2)
$storageAccountSku = "StandardV2_LRS"
# Note that kind provided is FileStorage. Combining this with a valid selected
# SKU will result in an HDD provisioned v2 file share with the selected
# redundancy. It is also possible to other types of storage accounts with the
# New-AzResource cmdlet, however, we recommend using the New-AzStorageAccount
# cmdlet instead.
$storageAccount = New-AzResource `
-ResourceType "Microsoft.Storage/storageAccounts" `
-ResourceGroupName $resourceGroupName `
-ResourceName $storageAccountName `
-Location $region `
-Kind "FileStorage" `
-Sku @{ Name = $storageAccountSku } `
-Confirm:$false
resourceGroupName="<my-resource-group>"
storageAccountName="<my-storage-account-name>"
region="<my-region>"
# Valid SKUs are StandardV2_LRS (HDD Local provisioned v2), StandardV2_ZRS (HDD
# Zone provisioned v2), StandardV2_GRS (HDD Geo provisioned v2),
# StandardV2_GZRS (HDD GeoZone provisioned v2)
storageAccountSku="StandardV2_LRS"
# Note that kind provided is FileStorage. Combining this with a valid selected
# SKU will result in an HDD provisioned v2 file share with the selected
# redundancy. It is also possible to other types of storage accounts with the
# az resource create command, however, we recommend using the az storage account
# create command instead.
storageAccount=$(az resource create \
--resource-type "Microsoft.Storage/storageAccounts" \
--resource-group $resourceGroupName \
--name $storageAccountName \
--is-full-object \
--properties "{\"location\":\"$region\",\"kind\":\"FileStorage\",\"sku\":{\"name\":\"$storageAccountSku\"},\"properties\":{}}" \
--query "id" \
--output tsv
)
创建预配 v1 或即用即付存储帐户 (Azure CLI)
若要使用 Azure CLI 创建预配 v1 或即用即付存储帐户,请使用 az storage account create 命令。 此命令有许多选项;此处只显示了必需的选项。 若要详细了解高级选项,请参阅 az storage account create 命令文档。
$shareName = "<file-share>"
# The provisioned storage size of the share in GiB. Valid range is 32 to
# 262,144.
$provisionedStorageGib = 1024
# The provisioned IOPS of the share. This is set to null here to get the
# recommended IOPS for the amount of provisioned storage provided, however, you
# can override this value if you have detail about how many IOPS your workload
# requires.
$provisionedIops = $null
# The provisioned throughput in MiB / sec of the share. This is set to null
# here to get the recommended throughput for the amount of provisioned storage
# provided, however, you can override this value if you have detail about how
# much throughput your workload requires.
$provisionedThroughputMibPerSec = $null
# Build file share properties for provisioning
$fileShareProperties = @{ shareQuota = $provisionedStorageGib }
if ($null -ne $provisionedIops) {
$fileShareProperties += @{ provisionedIops = $provisionedIops }
}
if ($null -ne $provisionedThroughputMibPerSec) {
$fileShareProperties += @{
provisionedBandwidthMibps = $provisionedThroughputMibPerSec
}
}
# Build resource ID for desired file share
$resourceId = $storageAccount.ResourceId
$resourceId += "/fileServices/default/shares/$shareName"
# Create resource
New-AzResource `
-ResourceId $resourceId `
-Properties $fileShareProperties `
-Confirm:$false | `
Out-Null
shareName="<file-share>"
# The provisioned storage size of the share in GiB. Valid range is 32 to
# 262,144.
provisionedStorageGib=1024
# The provisioned IOPS of the share. This is set to the empty string here to
# get the recommended IOPS for the amount of provisioned storage provided,
# however, you can override this value if you have detail about how many IOPS
# your workload requires.
provisionedIops=""
# The provisioned throughput in MiB / sec of the share. This is set to null
# here to get the recommended throughput for the amount of provisioned storage
# provided, however, you can override this value if you have detail about how
# much throughput your workload requires.
provisionedThroughputMibPerSec=""
# Build file share properties JSON.
fileShareProperties="{\"shareQuota\":$provisionedStorageGib"
if [ ! -z "${provisionedIops}" ]; then
fileShareProperties="$fileShareProperties,\"provisionedIops\":"
fileShareProperties="$fileShareProperties$provisionedIops"
fi
if [ ! -z "${provisionedThroughputMibPerSec}" ]; then
fileShareProperties="$fileShareProperties,\"provisionedBandwidthMibps\":"
fileShareProperties="$fileShareProperties$provisionedThroughputMibPerSec"
fi
fileShareProperties="$fileShareProperties}"
# Build resource ID for desired file share
resourceId="$storageAccount/fileServices/default/shares/$shareName"
# Create resource
az resource create \
--id $resourceId \
--properties $fileShareProperties \
--output none
$shareName = "<file-share>"
# The provisioned storage size of the share in GiB. Valid range is 100 to
# 102,400.
$provisionedStorageGib = 1024
# The protocol chosen for the file share. Valid set contains "SMB" and "NFS".
$protocol = "SMB"
New-AzRmStorageShare `
-ResourceGroupName $resourceGroupName `
-StorageAccountName $storageAccountName `
-Name $shareName `
-QuotaGiB $provisionedStorageGib `
-EnabledProtocol $protocol | `
Out-Null
shareName="<file-share>"
# The provisioned storage size of the share in GiB. Valid range is 100 to
# 102,400.
provisionedStorageGib=1024
# The protocol chosen for the file share. Valid set contains "SMB" and "NFS".
protocol="SMB"
az storage share-rm create \
--resource-group $resourceGroupName \
--storage-account $storageAccountName \
--name $shareName \
--quota $provisionedStorageGib \
--enabled-protocols $protocol \
--output none
# The path to the file share resource to be modified.
$resourceGroupName = "<resource-group>"
$storageAccountName = "<storage-account>"
$fileShareName = "<file-share>"
# The provisioning desired on the file share. Set these values to $null if no
# change is desired.
$provisionedStorageGib = 10240
$provisionedIops = 10000
$provisionedThroughputMibPerSec = 2048
# Get the resource ID of the storage account
$storageAccount = Get-AzResource `
-ResourceType "Microsoft.Storage/storageAccounts" `
-ResourceGroupName $resourceGroupName `
-ResourceName $storageAccountName
# Build the resource ID of the file share
$resourceId = $storageAccount.ResourceId
$resourceId += "/fileServices/default/shares/$fileShareName"
# Build the properties to be updated for the file share
$fileShareProperties = @{}
if ($null -ne $provisionedStorageGib) {
$fileShareProperties += @{ shareQuota = $provisionedStorageGib }
}
if ($null -ne $provisionedIops) {
$fileShareProperties += @{ provisionedIops = $provisionedIops }
}
if ($null -ne $provisionedThroughputMibPerSec) {
$fileShareProperties += @{
provisionedBandwidthMibps = $provisionedThroughputMibPerSec
}
}
# Update file share with new provisioning
Set-AzResource `
-ResourceId $resourceId `
-Properties $fileShareProperties `
-Confirm:$false
# The path to the file share resource to be modified.
resourceGroupName="<resource-group>"
storageAccountName="<storage-account>"
fileShareName="<file-share>"
# The provisioning desired on the file share. Set these values to the empty
# string if no change is desired.
provisionedStorageGib=10240
provisionedIops=10000
provisionedThroughputMibPerSec=2048
# Get the resource ID of the storage account
storageAccount=$(az resource show \
--resource-type "Microsoft.Storage/storageAccounts" \
--resource-group $resourceGroupName \
--name $storageAccountName \
--query "id" \
--output tsv
)
# Build the resource ID of the file share
resourceId="$storageAccount/fileServices/default/shares/$fileShareName"
# Build the properties to be updated for the file share
fileShareProperties="{"
if [ -z "${provisionedStorageGib}" ]; then
provisionedStorageGib=$(az resource show \
--ids $resourceId \
--query "properties.shareQuota" \
--output tsv
)
fi
fileShareProperties="$fileShareProperties\"shareQuota\":"
fileShareProperties="$fileShareProperties$provisionedStorageGib"
if [ -z "${provisionedIops}" ]; then
provisionedIops=$(az resource show \
--ids $resourceId \
--query "properties.provisionedIops" \
--output tsv
)
fi
fileShareProperties="$fileShareProperties,\"provisionedIops\":"
fileShareProperties="$fileShareProperties$provisionedIops"
if [ -z "${provisionedThroughputMibPerSec}" ]; then
provisionedThroughputMibPerSec=$(az resource show \
--ids $resourceId \
--query "properties.provisionedBandwidthMibps" \
--output tsv
)
fi
fileShareProperties="$fileShareProperties,\"provisionedBandwidthMibps\":"
fileShareProperties="$fileShareProperties$provisionedThroughputMibPerSec"
fileShareProperties="$fileShareProperties}"
# Update file share with new provisioning
az resource patch \
--ids $resourceId \
--properties $fileShareProperties
# The path to the file share resource to be modified.
resourceGroupName="<resource-group>"
storageAccountName="<storage-account>"
fileShareName="<file-share>"
# The provisioning desired on the file share.
provisionedStorageGib=10240
# Update the file share provisioning.
az storage share-rm update \
--resource-group $resourceGroupName \
--storage-account $storageAccountName \
--name $fileShareName \
--quota $provisionedStorageGib
# The path to the file share resource to be modified.
resourceGroupName="<resource-group>"
storageAccountName="<storage-account>"
fileShareName="<file-share>"
# The settings to be changed on the file share. Set to the empty string to skip
# setting.
accessTier="Cool"
quotaGib=""
command="az storage share-rm update --resource-group $resourceGroupName"
command="$command --storage-account $storageAccountName --name $fileShareName"
if [ ! -z "${accessTier}" ]; then
command="$command --access-tier $accessTier"
fi
if [ ! -z "${quotaGib}" ]; then
command="$command --quota $quotaGib"
fi
# Update file share (command is in variable)
$command