Skip to content

Commit 8ebf669

Browse files
authored
Merge pull request #2776 from wastoresh/release-1.7.0
RDBug 6919611:[PSH] Get-AzureRmStorageAccountKey: change the cmdlets …
2 parents 52f6b56 + 9604f2c commit 8ebf669

9 files changed

+185
-5
lines changed

ChangeLog.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
##2016.07.11 version 1.6.0
1+
##2016.08.22 version 1.7.0
2+
* Azure Storage
3+
* Change the return type of Get-AzureRmStorageAccountKey cmdlet, to make both of following works (Mitigate breaking change from 1.4.0)
4+
- $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $groupname -Name $accountname).Key1
5+
- $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 (Mitigate 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 (Mitigate 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
12+
13+
##2016.07.11 version 1.6.0
214
* **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:
315
* Correct implementation of –WhatIf functionality, allowing a user to determine the effects of a cmdlet or script without making any actual changes
416
* Control over prompting using a session-wide $ConfirmPreference, so that the user is prompted based on the impact of a prospective change (as reported in the ConfirmImpact setting in the cmdlet)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +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" />
148+
<Compile Include="Models\StorageAccountKeys.cs" />
149+
<Compile Include="Models\StorageAccountRegenerateKeyResponse.cs" />
147150
<Compile Include="Properties\AssemblyInfo.cs" />
148151
<Compile Include="StorageAccount\GetAzureStorageAccount.cs" />
149152
<Compile Include="StorageAccount\GetAzureStorageAccountKey.cs" />
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,96 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Configuration>
33
<ViewDefinitions>
4+
<View>
5+
<Name>Microsoft.Azure.Management.Storage.Models.StorageAccountRegenerateKeyResponse</Name>
6+
<ViewSelectedBy>
7+
<TypeName>Microsoft.Azure.Management.Storage.Models.StorageAccountRegenerateKeyResponse</TypeName>
8+
</ViewSelectedBy>
9+
<ListControl>
10+
<ListEntries>
11+
<ListEntry>
12+
<ListItems>
13+
<ListItem>
14+
<PropertyName>Keys</PropertyName>
15+
</ListItem>
16+
</ListItems>
17+
</ListEntry>
18+
</ListEntries>
19+
</ListControl>
20+
</View>
21+
<View>
22+
<Name>Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount</Name>
23+
<ViewSelectedBy>
24+
<TypeName>Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount</TypeName>
25+
</ViewSelectedBy>
26+
<ListControl>
27+
<ListEntries>
28+
<ListEntry>
29+
<ListItems>
30+
<ListItem>
31+
<PropertyName>ResourceGroupName</PropertyName>
32+
</ListItem>
33+
<ListItem>
34+
<PropertyName>StorageAccountName</PropertyName>
35+
</ListItem>
36+
<ListItem>
37+
<PropertyName>Id</PropertyName>
38+
</ListItem>
39+
<ListItem>
40+
<PropertyName>Location</PropertyName>
41+
</ListItem>
42+
<ListItem>
43+
<PropertyName>Sku</PropertyName>
44+
</ListItem>
45+
<ListItem>
46+
<PropertyName>Kind</PropertyName>
47+
</ListItem>
48+
<ListItem>
49+
<PropertyName>Encryption</PropertyName>
50+
</ListItem>
51+
<ListItem>
52+
<PropertyName>AccessTier</PropertyName>
53+
</ListItem>
54+
<ListItem>
55+
<PropertyName>CreationTime</PropertyName>
56+
</ListItem>
57+
<ListItem>
58+
<PropertyName>CustomDomain</PropertyName>
59+
</ListItem>
60+
<ListItem>
61+
<PropertyName>LastGeoFailoverTime</PropertyName>
62+
</ListItem>
63+
<ListItem>
64+
<PropertyName>PrimaryEndpoints</PropertyName>
65+
</ListItem>
66+
<ListItem>
67+
<PropertyName>PrimaryLocation</PropertyName>
68+
</ListItem>
69+
<ListItem>
70+
<PropertyName>ProvisioningState</PropertyName>
71+
</ListItem>
72+
<ListItem>
73+
<PropertyName>SecondaryEndpoints</PropertyName>
74+
</ListItem>
75+
<ListItem>
76+
<PropertyName>SecondaryLocation</PropertyName>
77+
</ListItem>
78+
<ListItem>
79+
<PropertyName>StatusOfPrimary</PropertyName>
80+
</ListItem>
81+
<ListItem>
82+
<PropertyName>StatusOfSecondary</PropertyName>
83+
</ListItem>
84+
<ListItem>
85+
<PropertyName>Tags</PropertyName>
86+
</ListItem>
87+
<ListItem>
88+
<PropertyName>Context</PropertyName>
89+
</ListItem>
90+
</ListItems>
91+
</ListEntry>
92+
</ListEntries>
93+
</ListControl>
94+
</View>
495
</ViewDefinitions>
596
</Configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace Microsoft.Azure.Management.Storage.Models
4+
{
5+
public enum AccountType
6+
{
7+
StandardLRS = 0,
8+
StandardZRS = 1,
9+
StandardGRS = 2,
10+
StandardRAGRS = 3,
11+
PremiumLRS = 4
12+
}
13+
}

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
3+
namespace Microsoft.Azure.Management.Storage.Models
4+
{
5+
6+
public class StorageAccountKeys : List<StorageAccountKey>
7+
{
8+
public StorageAccountKeys(IList<StorageAccountKey> storageKeys) : base()
9+
{
10+
this.AddRange(storageKeys);
11+
this.Key1 = storageKeys[0].Value;
12+
this.Key2 = storageKeys[1].Value;
13+
}
14+
15+
public string Key1 { get; set; }
16+
public string Key2 { get; set; }
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
3+
namespace Microsoft.Azure.Management.Storage.Models
4+
{
5+
class StorageAccountRegenerateKeyResponse
6+
{
7+
public StorageAccountRegenerateKeyResponse(StorageAccountListKeysResult result)
8+
{
9+
if (result.Keys != null)
10+
{
11+
StorageAccountKeys = new StorageAccountKeys(result.Keys);
12+
Keys = result.Keys;
13+
}
14+
}
15+
public StorageAccountKeys StorageAccountKeys { get; set; }
16+
public IList<StorageAccountKey> Keys { get; set; }
17+
}
18+
}

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

Lines changed: 4 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.Get, StorageAccountKeyNounStr), OutputType(typeof(StorageAccountKey))]
21+
[Cmdlet(VerbsCommon.Get, StorageAccountKeyNounStr), OutputType(typeof(StorageAccountKeys))]
2222
public class GetAzureStorageAccountKeyCommand : StorageAccountBaseCmdlet
2323
{
2424
[Parameter(
@@ -46,7 +46,9 @@ public override void ExecuteCmdlet()
4646
this.ResourceGroupName,
4747
this.Name).Keys;
4848

49-
WriteObject(storageKeys);
49+
StorageAccountKeys returnValue = new StorageAccountKeys(storageKeys);
50+
51+
WriteObject(returnValue);
5052
}
5153
}
5254
}

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)