Skip to content

Commit e7b7343

Browse files
committed
RDBug 7069788:[PSH] fix the breaking change on New/Get/Set-AzureRMStorageAccount for Sku.Name, and New-AzureRMstorageAccountKey
1 parent 163a491 commit e7b7343

File tree

6 files changed

+73
-3
lines changed

6 files changed

+73
-3
lines changed

ChangeLog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
##2016.08.22 version 1.7.0
22
* Azure Storage
3-
* Change the return type of Get-AzureRmStorageAccountKey cmdlet, to make both of following works (To migrate a breaking change from 1.4.0)
3+
* Change the return type of Get-AzureRmStorageAccountKey cmdlet, to make both of following works (Migrate breaking change from 1.4.0)
44
- $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $groupname -Name $accountname).Key1
55
- $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $groupname -Name $accountname)[0].Value
6+
* Change the return type of New/Get/Set-AzureRMStorageAccount cmdlet by add back AccountType, to make both of following works (Migrate breaking change from 1.4.0)
7+
- $AccountType = (Get-AzureRmStorageAccount -ResourceGroupName $groupname -Name $accountname).AccountType
8+
- $AccountType = (Get-AzureRmStorageAccount -ResourceGroupName $groupname -Name $accountname).Sku.Name
9+
* Change the return type of New-AzureRmStorageAccountKey cmdlet, to make both of following works (Migrate breaking change from 1.4.0)
10+
- $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $groupname -Name $accountname -KeyName $keyname).StorageAccountKeys.Key1
11+
- $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $groupname -Name $accountname -KeyName $keyname).Keys[0].Value
612

713
##2016.07.11 version 1.6.0
814
* **Behavioral change for -Force, –Confirm and $ConfirmPreference parameters for all cmdlets. We are changing this implementation to be in line with PowerShell guidelines. For most cmdlets, this means removing the Force parameter and to skip the ShouldProcess prompt, users will need to include the parameter: ‘-Confirm:$false’ in their PowerShell scripts.** This changes are addressing following issues:

src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@
142142
<Compile Include="..\..\..\Common\Commands.Common.Storage\Adapters\ARM.Storage.5\ARMStorageService.cs">
143143
<Link>Common\ARMStorageService.cs</Link>
144144
</Compile>
145+
<Compile Include="Models\AccountType.cs" />
145146
<Compile Include="Models\PSStorageAccount.cs" />
146147
<Compile Include="Models\PSUsage.cs" />
147148
<Compile Include="Models\StorageAccountKeys.cs" />
149+
<Compile Include="Models\StorageAccountRegenerateKeyResponse.cs" />
148150
<Compile Include="Properties\AssemblyInfo.cs" />
149151
<Compile Include="StorageAccount\GetAzureStorageAccount.cs" />
150152
<Compile Include="StorageAccount\GetAzureStorageAccountKey.cs" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Microsoft.Azure.Management.Storage.Models
8+
{
9+
public enum AccountType
10+
{
11+
StandardLRS = 0,
12+
StandardZRS = 1,
13+
StandardGRS = 2,
14+
StandardRAGRS = 3,
15+
PremiumLRS = 4
16+
}
17+
}

src/ResourceManager/Storage/Commands.Management.Storage/Models/PSStorageAccount.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
3131
this.Id = storageAccount.Id;
3232
this.Location = storageAccount.Location;
3333
this.Sku = storageAccount.Sku;
34+
this.AccountType = GetAccountType(storageAccount.Sku);
3435
this.Encryption = storageAccount.Encryption;
3536
this.Kind = storageAccount.Kind;
3637
this.AccessTier = storageAccount.AccessTier;
@@ -56,6 +57,7 @@ public PSStorageAccount(StorageModels.StorageAccount storageAccount)
5657
public string Location { get; set; }
5758

5859
public Sku Sku { get; set; }
60+
public AccountType AccountType { get; set; }
5961
public Kind? Kind { get; set; }
6062
public Encryption Encryption { get; set; }
6163
public AccessTier? AccessTier { get; set; }
@@ -121,5 +123,26 @@ public override string ToString()
121123
// Allow listing storage contents through piping
122124
return null;
123125
}
126+
127+
/// <summary>
128+
/// Convert SkuName to Account Type
129+
/// </summary>
130+
public static AccountType GetAccountType(Sku sku)
131+
{
132+
switch (sku.Name)
133+
{
134+
case SkuName.PremiumLRS:
135+
return AccountType.PremiumLRS;
136+
case SkuName.StandardLRS:
137+
return AccountType.StandardLRS;
138+
case SkuName.StandardRAGRS:
139+
return AccountType.StandardRAGRS;
140+
case SkuName.StandardZRS:
141+
return AccountType.StandardZRS;
142+
case SkuName.StandardGRS:
143+
default:
144+
return AccountType.StandardGRS;
145+
}
146+
}
124147
}
125148
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Microsoft.Azure.Management.Storage.Models
8+
{
9+
class StorageAccountRegenerateKeyResponse
10+
{
11+
public StorageAccountRegenerateKeyResponse(StorageAccountListKeysResult result)
12+
{
13+
if (result.Keys !=null)
14+
{
15+
StorageAccountKeys = new StorageAccountKeys(result.Keys);
16+
Keys = result.Keys;
17+
}
18+
}
19+
public StorageAccountKeys StorageAccountKeys { get; set; }
20+
public IList<StorageAccountKey> Keys { get; }
21+
}
22+
}

src/ResourceManager/Storage/Commands.Management.Storage/StorageAccount/NewAzureStorageAccountKey.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Management.Storage
2020
{
21-
[Cmdlet(VerbsCommon.New, StorageAccountKeyNounStr), OutputType(typeof(StorageAccountKey))]
21+
[Cmdlet(VerbsCommon.New, StorageAccountKeyNounStr), OutputType(typeof(StorageAccountKeys))]
2222
public class NewAzureStorageAccountKeyCommand : StorageAccountBaseCmdlet
2323
{
2424
private const string Key1 = "key1";
@@ -59,7 +59,7 @@ public override void ExecuteCmdlet()
5959
this.Name,
6060
this.KeyName);
6161

62-
WriteObject(keys);
62+
WriteObject(new StorageAccountRegenerateKeyResponse(keys));
6363
}
6464
}
6565
}

0 commit comments

Comments
 (0)