Skip to content

Commit d3243ca

Browse files
authored
Merge pull request #295727 from VincentLiu777/patch-1
Changed Pv2 File Shares PowerShell Instructions
2 parents a8c3260 + ff494e0 commit d3243ca

File tree

1 file changed

+44
-207
lines changed

1 file changed

+44
-207
lines changed

articles/storage/files/storage-how-to-create-file-share.md

Lines changed: 44 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: How to create and delete SMB and NFS Azure file share by using the
55
author: khdownie
66
ms.service: azure-file-storage
77
ms.topic: how-to
8-
ms.date: 01/10/2025
8+
ms.date: 03/05/2025
99
ms.author: kendownie
1010
ms.custom: devx-track-azurecli, references_regions, devx-track-azurepowershell
1111
---
@@ -162,33 +162,20 @@ The final step to create the storage account is to select the **Create** button
162162

163163
# [PowerShell](#tab/azure-powershell)
164164
### Create a provisioned v2 storage account (PowerShell)
165-
The Az.Storage PowerShell module doesn't currently support creating provisioned v2 storage accounts. To create a provisioned v2 storage account using PowerShell, use the `New-AzResource` cmdlet. Storage account properties can be set using the `-Properties` parameter of the `New-AzResource` cmdlet. See [Microsoft.Storage resource provider REST API documentation](/rest/api/storagerp/storage-accounts/create#request-body) to learn more about the possible property names.
165+
166+
To create a provisioned v2 storage account using PowerShell, use the `New-AzStorageAccount` cmdlet in the Az.Storage PowerShell module. This cmdlet has many options; only the required options are shown. To learn more about advanced options, see the [`New-AzStorageAccount` cmdlet documentation](/powershell/module/az.storage/new-azstorageaccount).
166167

167168
To create a storage account for provisioned v2 file shares, use the following command. Remember to replace the values for the variables `$resourceGroupName`, `$storageAccountName`, `$region`, and `$storageAccountSku` with the desired values for your storage account deployment.
168169

169170
```PowerShell
170171
$resourceGroupName = "<my-resource-group>"
171172
$storageAccountName = "<my-storage-account-name>"
172173
$region = "<my-region>"
173-
174-
# Valid SKUs are StandardV2_LRS (HDD Local provisioned v2), StandardV2_ZRS (HDD
175-
# Zone provisioned v2), StandardV2_GRS (HDD Geo provisioned v2),
176-
# StandardV2_GZRS (HDD GeoZone provisioned v2)
174+
$storageAccountKind = "FileStorage"
175+
# Valid SKUs for provisioned v2 HDD file share are 'StandardV2_LRS' (HDD Local Pv2), 'StandardV2_GRS' (HDD Geo Pv2), 'StandardV2_ZRS' (HDD Zone Pv2), 'StandardV2_GZRS' (HDD GeoZone Pv2).
177176
$storageAccountSku = "StandardV2_LRS"
178177
179-
# Note that kind provided is FileStorage. Combining this with a valid selected
180-
# SKU will result in an HDD provisioned v2 file share with the selected
181-
# redundancy. It is also possible to other types of storage accounts with the
182-
# New-AzResource cmdlet, however, we recommend using the New-AzStorageAccount
183-
# cmdlet instead.
184-
$storageAccount = New-AzResource `
185-
-ResourceType "Microsoft.Storage/storageAccounts" `
186-
-ResourceGroupName $resourceGroupName `
187-
-ResourceName $storageAccountName `
188-
-Location $region `
189-
-Kind "FileStorage" `
190-
-Sku @{ Name = $storageAccountSku } `
191-
-Confirm:$false
178+
New-AzStorageAccount -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -SkuName $storageAccountSku -Kind $storageAccountKind -Location $region
192179
```
193180

194181
### Create a provisioned v1 or pay-as-you-go storage account (PowerShell)
@@ -224,34 +211,20 @@ $storageAccount = New-AzStorageAccount `
224211

225212
# [Azure CLI](#tab/azure-cli)
226213
### Create a provisioned v2 storage account (Azure CLI)
227-
The Azure CLI storage command group doesn't currently support creating provisioned v2 storage accounts. To create a provisioned v2 storage account using Azure CLI, use the `az resource create` command. Storage account properties can be set using the `--properties` parameter of the command. See [Microsoft.Storage resource provider REST API documentation](/rest/api/storagerp/storage-accounts/create#request-body) to learn more about the possible property names.
214+
To create a provisioned v2 storage account using Azure CLI, use the `az storage account create` command. This command has many options; only the required options are shown. To learn more about the advanced options, see the [`az storage account create` command documentation](/cli/azure/storage/account).
228215

229-
To create a storage account for provisioned v2 file shares, use the following command. Remember to replace the values for the variables `resourceGroupName`, `storageAccountName`, `region`, and `storageAccountSku` with the desired values for your storage account deployment.
216+
To create a storage account for provisioned v2 file shares, use the following command. Remember to replace the values for the variables `resourceGroupName`, `storageAccountName`, `region`, `storageAccountKind`, and `storageAccountSku` with the desired values for your storage account deployment.
230217

231218
```bash
232219
resourceGroupName="<my-resource-group>"
233220
storageAccountName="<my-storage-account-name>"
234221
region="<my-region>"
222+
storageAccountKind="FileStorage"
235223

236-
# Valid SKUs are StandardV2_LRS (HDD Local provisioned v2), StandardV2_ZRS (HDD
237-
# Zone provisioned v2), StandardV2_GRS (HDD Geo provisioned v2),
238-
# StandardV2_GZRS (HDD GeoZone provisioned v2)
224+
# Valid SKUs for provisioned v2 HDD file share are 'StandardV2_LRS' (HDD Local Pv2), 'StandardV2_GRS' (HDD Geo Pv2), 'StandardV2_ZRS' (HDD Zone Pv2), 'StandardV2_GZRS' (HDD GeoZone Pv2).
239225
storageAccountSku="StandardV2_LRS"
240226

241-
# Note that kind provided is FileStorage. Combining this with a valid selected
242-
# SKU will result in an HDD provisioned v2 file share with the selected
243-
# redundancy. It is also possible to other types of storage accounts with the
244-
# az resource create command, however, we recommend using the az storage account
245-
# create command instead.
246-
storageAccount=$(az resource create \
247-
--resource-type "Microsoft.Storage/storageAccounts" \
248-
--resource-group $resourceGroupName \
249-
--name $storageAccountName \
250-
--is-full-object \
251-
--properties "{\"location\":\"$region\",\"kind\":\"FileStorage\",\"sku\":{\"name\":\"$storageAccountSku\"},\"properties\":{}}" \
252-
--query "id" \
253-
--output tsv
254-
)
227+
az storage account create --resource-group $resourceGroupName --name $storageAccountName --location $region --kind $storageAccountKind --sku $storageAccountSku --output none
255228
```
256229

257230
### Create a provisioned v1 or pay-as-you-go storage account (Azure CLI)
@@ -325,101 +298,44 @@ Follow these instructions to create a new Azure file share using the Azure porta
325298
5. Select **Review + create** and then **Create** to create the Azure file share.
326299

327300
# [PowerShell](#tab/azure-powershell)
328-
You can create an Azure file share with the `New-AzResource` cmdlet. The following PowerShell commands assume you set the `$storageAccount` variable when creating a storage account in the Azure PowerShell section.
301+
You can create a provisioned v2 Azure file share with the `New-AzRmStorageShare` cmdlet. The following PowerShell commands assume you set the variables `$resourceGroupName` and `$storageAccountName` as defined in the "Create Storage Account" section.
329302

330-
To create a provisioned v2 file share, use the following command. Remember to replace the values for the variables `$shareName`, `$provisionedStorageGiB`, `$provisionedIops`, and `$provisionedThroughputMibPerSec` with the desired selections for your file share deployment.
303+
To create a provisioned v2 file share, use the following command. Remember to replace the values for the variables `$shareName` and `$provisionedStorageGib` with the desired selections for your file share deployment.
331304

332305
```powershell
333-
$shareName = "<file-share>"
306+
$shareName = "<name-of-the-file-share>"
334307
335-
# The provisioned storage size of the share in GiB. Valid range is 32 to
336-
# 262,144.
308+
# The provisioned storage size of the share in GiB. Valid range is 32 to 262,144.
337309
$provisionedStorageGib = 1024
338310
339-
# The provisioned IOPS of the share. This is set to null here to get the
340-
# recommended IOPS for the amount of provisioned storage provided, however, you
341-
# can override this value if you have detail about how many IOPS your workload
342-
# requires.
343-
$provisionedIops = $null
344-
345-
# The provisioned throughput in MiB / sec of the share. This is set to null
346-
# here to get the recommended throughput for the amount of provisioned storage
347-
# provided, however, you can override this value if you have detail about how
348-
# much throughput your workload requires.
349-
$provisionedThroughputMibPerSec = $null
350-
351-
# Build file share properties for provisioning
352-
$fileShareProperties = @{ shareQuota = $provisionedStorageGib }
353-
354-
if ($null -ne $provisionedIops) {
355-
$fileShareProperties += @{ provisionedIops = $provisionedIops }
356-
}
357-
358-
if ($null -ne $provisionedThroughputMibPerSec) {
359-
$fileShareProperties += @{
360-
provisionedBandwidthMibps = $provisionedThroughputMibPerSec
361-
}
362-
}
363-
364-
# Build resource ID for desired file share
365-
$resourceId = $storageAccount.ResourceId
366-
$resourceId += "/fileServices/default/shares/$shareName"
311+
# If you do not specify on the ProvisionedBandwidthMibps and ProvisionedIops, the deployment will use the recommended provisioning.
312+
$provisionedIops = 3000
313+
$provisionedThroughputMibPerSec = 130
367314
368-
# Create resource
369-
New-AzResource `
370-
-ResourceId $resourceId `
371-
-Properties $fileShareProperties `
372-
-Confirm:$false | `
373-
Out-Null
315+
New-AzRmStorageShare -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -ShareName $shareName -QuotaGiB $provisionedStorageGib;
316+
# -ProvisionedBandwidthMibps $provisionedThroughputMibPerSec -ProvisionedIops $provisionedIops
317+
$f = Get-AzRmStorageShare -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -ShareName $shareName;
318+
$f | fl
374319
```
375320

376321
# [Azure CLI](#tab/azure-cli)
377-
You can create an Azure file share with the `az resource create` command. The following commands assume you set the `storageAccount` variable when creating a storage account in the Azure CLI section.
322+
You can create an Provisioned v2 Azure file share with [`az storage share-rm create`](/cli/azure/storage/share-rm#az-storage-share-rm-create) command. The following PowerShell commands assume you set the variables `resourceGroupName` and `storageAccountName` as defined in the creating a storage account with Azure CLI section.
378323

379-
To create a provisioned v2 file share, use the following command. Remember to replace the values for the variables `shareName`, `provisionedStorageGib`, `provisionedIops`, and `provisionedThroughputMibPerSec` with the desired selections for your file share deployment.
324+
To create a provisioned v2 file share, use the following command. Remember to replace the values for the variables `shareName`, `provisionedStorageGib` with the desired selections for your file share deployment.
380325

381326
```bash
382327
shareName="<file-share>"
383328

384-
# The provisioned storage size of the share in GiB. Valid range is 32 to
329+
# The provisioned storage size of the share in GiB. Valid range is 32 to
385330
# 262,144.
386331
provisionedStorageGib=1024
387332

388-
# The provisioned IOPS of the share. This is set to the empty string here to
389-
# get the recommended IOPS for the amount of provisioned storage provided,
390-
# however, you can override this value if you have detail about how many IOPS
391-
# your workload requires.
392-
provisionedIops=""
393-
394-
# The provisioned throughput in MiB / sec of the share. This is set to null
395-
# here to get the recommended throughput for the amount of provisioned storage
396-
# provided, however, you can override this value if you have detail about how
397-
# much throughput your workload requires.
398-
provisionedThroughputMibPerSec=""
399-
400-
# Build file share properties JSON.
401-
fileShareProperties="{\"shareQuota\":$provisionedStorageGib"
402-
403-
if [ ! -z "${provisionedIops}" ]; then
404-
fileShareProperties="$fileShareProperties,\"provisionedIops\":"
405-
fileShareProperties="$fileShareProperties$provisionedIops"
406-
fi
333+
# If you do not specify on the ProvisionedBandwidthMibps and ProvisionedIops, the deployment will use the recommended provisioning.
334+
provisionedIops=3000
335+
provisionedThroughputMibPerSec=130
407336

408-
if [ ! -z "${provisionedThroughputMibPerSec}" ]; then
409-
fileShareProperties="$fileShareProperties,\"provisionedBandwidthMibps\":"
410-
fileShareProperties="$fileShareProperties$provisionedThroughputMibPerSec"
411-
fi
412-
413-
fileShareProperties="$fileShareProperties}"
414-
415-
# Build resource ID for desired file share
416-
resourceId="$storageAccount/fileServices/default/shares/$shareName"
417-
418-
# Create resource
419-
az resource create \
420-
--id $resourceId \
421-
--properties $fileShareProperties \
422-
--output none
337+
az storage share-rm create --resource-group $resourceGroupName --name $shareName --storage-account $storageAccountName --quota $provisionedStorageGib
338+
# --provisioned-iops $provisionedIops --provisioned-bandwidth-mibps $provisionedThroughputMibPerSec
423339
```
424340

425341
---
@@ -600,123 +516,44 @@ Follow these instructions to update the provisioning for your file share.
600516
5. Select **Save** to save provisioning changes. Storage, IOPS, and throughput changes are effective within a few minutes after a provisioning change.
601517

602518
# [PowerShell](#tab/azure-powershell)
603-
You can modify a provisioned v2 file share with the `Set-AzResource` cmdlet. Remember to replace the values for the variables `$resourceGroupName`, `$storageAccountName`, `$fileShareName`, `$provisionedStorageGib`, `$provisionedIops`, and `$provisionedThroughputMibPerSec` with the desired values for your file share.
519+
You can modify a provisioned v2 file share with the `Update-AzRmStorageShare` cmdlet. Remember to replace the values for the variables `$resourceGroupName`, `$storageAccountName`, `$shareName`, `$provisionedMibps`, `$provisionedIops`, and `$provisionedStorageGib` with the desired values for your file share.
604520

605521
```powershell
606522
# The path to the file share resource to be modified.
607-
$resourceGroupName = "<resource-group>"
608-
$storageAccountName = "<storage-account>"
609-
$fileShareName = "<file-share>"
523+
$resourceGroupName = "<my-resource-group>"
524+
$storageAccountName = "<my-storage-account-name>"
525+
$shareName = "<name-of-the-file-share>"
610526
611-
# The provisioning desired on the file share. Set these values to $null if no
527+
# The provisioning desired on the file share. Delete the parameters if no
612528
# change is desired.
613529
$provisionedStorageGib = 10240
614530
$provisionedIops = 10000
615531
$provisionedThroughputMibPerSec = 2048
616532
617-
# Get the resource ID of the storage account
618-
$storageAccount = Get-AzResource `
619-
-ResourceType "Microsoft.Storage/storageAccounts" `
620-
-ResourceGroupName $resourceGroupName `
621-
-ResourceName $storageAccountName
622-
623-
# Build the resource ID of the file share
624-
$resourceId = $storageAccount.ResourceId
625-
$resourceId += "/fileServices/default/shares/$fileShareName"
626-
627-
# Build the properties to be updated for the file share
628-
$fileShareProperties = @{}
629-
630-
if ($null -ne $provisionedStorageGib) {
631-
$fileShareProperties += @{ shareQuota = $provisionedStorageGib }
632-
}
633-
634-
if ($null -ne $provisionedIops) {
635-
$fileShareProperties += @{ provisionedIops = $provisionedIops }
636-
}
637-
638-
if ($null -ne $provisionedThroughputMibPerSec) {
639-
$fileShareProperties += @{
640-
provisionedBandwidthMibps = $provisionedThroughputMibPerSec
641-
}
642-
}
643-
644-
# Update file share with new provisioning
645-
Set-AzResource `
646-
-ResourceId $resourceId `
647-
-Properties $fileShareProperties `
648-
-Confirm:$false
533+
# Update the file share provisioning.
534+
Update-AzRmStorageShare -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -ShareName $shareName -ProvisionedBandwidthMibps $provisionedThroughputMibPerSec -ProvisionedIops $provisionedIops -QuotaGiB $provisionedStorageGib;
535+
$f = Get-AzRmStorageShare -ResourceGroupName $resourceGroupName -AccountName $storageAccountName -ShareName $shareName;
536+
$f | fl
649537
```
650538

651539
# [Azure CLI](#tab/azure-cli)
652-
You can modify a provisioned v2 file share with the `az resource patch` command. Remember to replace the value of variables `resourceGroupName`, `storageAccountName`, `fileShareName`, `provisionedStorageGib`, `provisionedIops`, and `provisionedThroughputMibPerSec` with the correct values for your file share.
540+
You can modify a provisioned v2 file share with the `az storage share-rm update` command. Remember to replace the values for the variables `resourceGroupName`, `storageAccountName`, `fileShareName`, `provisionedStorageGib`, `provisionedIops`, and `provisionedThroughputMibPerSec` with the desired values for your file share.
653541

654542
```bash
655543
# The path to the file share resource to be modified.
656544
resourceGroupName="<resource-group>"
657545
storageAccountName="<storage-account>"
658546
fileShareName="<file-share>"
659547

660-
# The provisioning desired on the file share. Set these values to the empty
661-
# string if no change is desired.
548+
# The provisioning desired on the file share. Delete the parameters if no
549+
# change is desired.
662550
provisionedStorageGib=10240
663551
provisionedIops=10000
664552
provisionedThroughputMibPerSec=2048
665553

666-
# Get the resource ID of the storage account
667-
storageAccount=$(az resource show \
668-
--resource-type "Microsoft.Storage/storageAccounts" \
669-
--resource-group $resourceGroupName \
670-
--name $storageAccountName \
671-
--query "id" \
672-
--output tsv
673-
)
674-
675-
# Build the resource ID of the file share
676-
resourceId="$storageAccount/fileServices/default/shares/$fileShareName"
677-
678-
# Build the properties to be updated for the file share
679-
fileShareProperties="{"
680-
681-
if [ -z "${provisionedStorageGib}" ]; then
682-
provisionedStorageGib=$(az resource show \
683-
--ids $resourceId \
684-
--query "properties.shareQuota" \
685-
--output tsv
686-
)
687-
fi
688-
689-
fileShareProperties="$fileShareProperties\"shareQuota\":"
690-
fileShareProperties="$fileShareProperties$provisionedStorageGib"
691-
692-
if [ -z "${provisionedIops}" ]; then
693-
provisionedIops=$(az resource show \
694-
--ids $resourceId \
695-
--query "properties.provisionedIops" \
696-
--output tsv
697-
)
698-
fi
699-
700-
fileShareProperties="$fileShareProperties,\"provisionedIops\":"
701-
fileShareProperties="$fileShareProperties$provisionedIops"
702-
703-
if [ -z "${provisionedThroughputMibPerSec}" ]; then
704-
provisionedThroughputMibPerSec=$(az resource show \
705-
--ids $resourceId \
706-
--query "properties.provisionedBandwidthMibps" \
707-
--output tsv
708-
)
709-
fi
710-
711-
fileShareProperties="$fileShareProperties,\"provisionedBandwidthMibps\":"
712-
fileShareProperties="$fileShareProperties$provisionedThroughputMibPerSec"
713-
714-
fileShareProperties="$fileShareProperties}"
554+
# Update the file share provisioning.
555+
az storage share-rm update --resource-group $resourceGroupName --name $shareName --storage-account $storageAccountName --quota $provisionedStorageGib --provisioned-iops $provisionedIops --provisioned-bandwidth-mibps $provisionedThroughputMibPerSec
715556

716-
# Update file share with new provisioning
717-
az resource patch \
718-
--ids $resourceId \
719-
--properties $fileShareProperties
720557
```
721558

722559
---

0 commit comments

Comments
 (0)