Skip to content

Commit db2017f

Browse files
authored
[Storage] Support share Accesstier (#13106)
1 parent a49544d commit db2017f

File tree

7 files changed

+500
-364
lines changed

7 files changed

+500
-364
lines changed

src/Storage/Storage.Management.Test/ScenarioTests/StorageFileTests.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ function Test-StorageFileShare
6868
$quotaGiB = 300
6969
$metadata = @{tag0="value0";tag1="value1";tag2="value2";tag3="value3"}
7070
$shareName2 = "share2"+ $rgname
71-
$stos | New-AzRmStorageShare -Name $shareName2 -QuotaGiB $quotaGiB -Metadata $metadata
71+
$stos | New-AzRmStorageShare -Name $shareName2 -QuotaGiB $quotaGiB -Metadata $metadata -AccessTier Cool
7272
$share = $stos | Get-AzRmStorageShare -Name $shareName2
7373
Assert-AreEqual $rgname $share.ResourceGroupName
7474
Assert-AreEqual $stoname $share.StorageAccountName
7575
Assert-AreEqual $shareName2 $share.Name
7676
Assert-AreEqual $quotaGiB $share.QuotaGiB
7777
Assert-AreEqual $metadata.Count $share.Metadata.Count
78+
Assert-AreEqual "Cool" $share.Accesstier
79+
Update-AzRmStorageShare -ResourceGroupName $rgname -StorageAccountName $stoname -Name $shareName2 -AccessTier Hot
80+
$share = $stos | Get-AzRmStorageShare -Name $shareName2
81+
Assert-AreEqual "Hot" $share.Accesstier
7882

7983
$shares = Get-AzRmStorageShare -ResourceGroupName $rgname -StorageAccountName $stoname
8084
Assert-AreEqual 2 $shares.Count

src/Storage/Storage.Management.Test/SessionRecords/Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageFileTests/TestStorageFileShare.json

Lines changed: 374 additions & 353 deletions
Large diffs are not rendered by default.

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Support create/update file share with access tier
22+
- `New-AzRmStorageShare`
23+
- `Update-AzRmStorageShare`
2124

2225
## Version 2.7.0
2326
* Supported enable/disable/get share soft delete properties on file Service of a Storage account

src/Storage/Storage.Management/File/NewAzureStorageShare.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ public int QuotaGiB
8787
[ValidateNotNull]
8888
public Hashtable Metadata { get; set; }
8989

90+
91+
[Parameter(
92+
Mandatory = false,
93+
HelpMessage = "Access tier for specific share. StorageV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium.")]
94+
[ValidateSet(ShareAccessTier.TransactionOptimized,
95+
ShareAccessTier.Premium,
96+
ShareAccessTier.Hot,
97+
ShareAccessTier.Cool,
98+
IgnoreCase = true)]
99+
[ValidateNotNullOrEmpty]
100+
public string AccessTier
101+
{
102+
get
103+
{
104+
return accessTier;
105+
}
106+
set
107+
{
108+
accessTier = value;
109+
}
110+
}
111+
private string accessTier = null;
112+
90113
public override void ExecuteCmdlet()
91114
{
92115
base.ExecuteCmdlet();
@@ -113,7 +136,8 @@ public override void ExecuteCmdlet()
113136
this.Name,
114137
new FileShare(
115138
metadata: MetadataDictionary,
116-
shareQuota: shareQuota));
139+
shareQuota: shareQuota,
140+
accessTier: accessTier));
117141

118142
WriteObject(new PSShare(share));
119143
}

src/Storage/Storage.Management/File/UpdateAzureStorageShare.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Management.Storage.Models;
16+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1617
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
1718
using Microsoft.Azure.Management.Storage;
1819
using Microsoft.Azure.Management.Storage.Models;
@@ -118,6 +119,28 @@ public int QuotaGiB
118119
[ValidateNotNull]
119120
public Hashtable Metadata { get; set; }
120121

122+
[Parameter(
123+
Mandatory = false,
124+
HelpMessage = "Access tier for specific share. StorageV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium.")]
125+
[ValidateSet(ShareAccessTier.TransactionOptimized,
126+
ShareAccessTier.Premium,
127+
ShareAccessTier.Hot,
128+
ShareAccessTier.Cool,
129+
IgnoreCase = true)]
130+
[ValidateNotNullOrEmpty]
131+
public string AccessTier
132+
{
133+
get
134+
{
135+
return accessTier;
136+
}
137+
set
138+
{
139+
accessTier = value;
140+
}
141+
}
142+
private string accessTier = null;
143+
121144
public override void ExecuteCmdlet()
122145
{
123146
base.ExecuteCmdlet();
@@ -153,7 +176,8 @@ public override void ExecuteCmdlet()
153176
this.Name,
154177
new FileShare(
155178
metadata: MetadataDictionary,
156-
shareQuota: shareQuota));
179+
shareQuota: shareQuota,
180+
accessTier: accessTier));
157181

158182
WriteObject(new PSShare(Share));
159183
}

src/Storage/Storage.Management/help/New-AzRmStorageShare.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ Creates a Storage file share.
1515
### AccountName (Default)
1616
```
1717
New-AzRmStorageShare [-ResourceGroupName] <String> [-StorageAccountName] <String> -Name <String>
18-
[-QuotaGiB <Int32>] [-Metadata <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
19-
[<CommonParameters>]
18+
[-QuotaGiB <Int32>] [-Metadata <Hashtable>] [-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>]
19+
[-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### AccountObject
2323
```
2424
New-AzRmStorageShare -StorageAccount <PSStorageAccount> -Name <String> [-QuotaGiB <Int32>]
25-
[-Metadata <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-Metadata <Hashtable>] [-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
26+
[<CommonParameters>]
2627
```
2728

2829
## DESCRIPTION
@@ -56,8 +57,37 @@ myshare
5657

5758
This command creates a Storage file share with Storage account object and share name.
5859

60+
### Example 3: Create a Storage file share with accesstier as Hot
61+
```
62+
PS C:\>$share = New-AzRmStorageShare -ResourceGroupName "myresourcegroup" -StorageAccountName "mystorageaccount" -Name "myshare" -AccessTier Hot
63+
64+
ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount
65+
66+
Name QuotaGiB EnabledProtocols AccessTier Deleted Version ShareUsageBytes
67+
---- -------- ---------------- ---------- ------- ------- ---------------
68+
myshare Hot
69+
```
70+
71+
This command creates a Storage file share with accesstier as Hot.
72+
5973
## PARAMETERS
6074

75+
### -AccessTier
76+
Access tier for specific share. StorageV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium.
77+
78+
```yaml
79+
Type: System.String
80+
Parameter Sets: (All)
81+
Aliases:
82+
Accepted values: TransactionOptimized, Premium, Hot, Cool
83+
84+
Required: False
85+
Position: Named
86+
Default value: None
87+
Accept pipeline input: False
88+
Accept wildcard characters: False
89+
```
90+
6191
### -DefaultProfile
6292
The credentials, account, tenant, and subscription used for communication with Azure.
6393

src/Storage/Storage.Management/help/Update-AzRmStorageShare.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,27 @@ Modifies a Storage file share.
1515
### AccountName (Default)
1616
```
1717
Update-AzRmStorageShare [-ResourceGroupName] <String> [-StorageAccountName] <String> -Name <String>
18-
[-QuotaGiB <Int32>] [-Metadata <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
19-
[<CommonParameters>]
18+
[-QuotaGiB <Int32>] [-Metadata <Hashtable>] [-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>]
19+
[-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### AccountObject
2323
```
2424
Update-AzRmStorageShare -Name <String> -StorageAccount <PSStorageAccount> [-QuotaGiB <Int32>]
25-
[-Metadata <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-Metadata <Hashtable>] [-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
26+
[<CommonParameters>]
2627
```
2728

2829
### ShareResourceId
2930
```
3031
Update-AzRmStorageShare [-ResourceId] <String> [-QuotaGiB <Int32>] [-Metadata <Hashtable>]
31-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
32+
[-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3233
```
3334

3435
### ShareObject
3536
```
3637
Update-AzRmStorageShare -InputObject <PSShare> [-QuotaGiB <Int32>] [-Metadata <Hashtable>]
37-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
38+
[-AccessTier <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3839
```
3940

4041
## DESCRIPTION
@@ -86,8 +87,37 @@ share2 5000
8687

8788
This command modifies share quota as 5000 GiB for all Storage file shares in a Storage account with pipeline.
8889

90+
### Example 4: Modify a Storage file share with accesstier as Cool
91+
```
92+
PS C:\>$share = Update-AzRmStorageShare -ResourceGroupName "myresourcegroup" -StorageAccountName "mystorageaccount" -Name "myshare" -AccessTier Cool
93+
94+
ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount
95+
96+
Name QuotaGiB EnabledProtocols AccessTier Deleted Version ShareUsageBytes
97+
---- -------- ---------------- ---------- ------- ------- ---------------
98+
myshare Cool
99+
```
100+
101+
This command modifies a Storage file share with accesstier as Cool.
102+
89103
## PARAMETERS
90104

105+
### -AccessTier
106+
Access tier for specific share. StorageV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium.
107+
108+
```yaml
109+
Type: System.String
110+
Parameter Sets: (All)
111+
Aliases:
112+
Accepted values: TransactionOptimized, Premium, Hot, Cool
113+
114+
Required: False
115+
Position: Named
116+
Default value: None
117+
Accept pipeline input: False
118+
Accept wildcard characters: False
119+
```
120+
91121
### -DefaultProfile
92122
The credentials, account, tenant, and subscription used for communication with Azure.
93123

0 commit comments

Comments
 (0)