Skip to content

Commit 3b3183e

Browse files
committed
Merge pull request Azure#100 from wastoresh/srp
Add cmdlets to list SRP account in a subscription
2 parents 272f05e + 88cbbde commit 3b3183e

18 files changed

+2320
-1236
lines changed

ChangeLog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@
6060
* Remove-AzureNetworkSecurityRuleConfig
6161
* Add-AzureNetworkSecurityRuleConfig
6262
* Set-AzureNetworkSecurityRuleConfig
63+
* Azure Storage
64+
* Added cmdlets in AzureResourceManager Mode
65+
* New-AzureStorageAccount
66+
* Get-AzureStorageAccount
67+
* Set-AzureStorageAccount
68+
* Remove-AzureStorageAccount
69+
* New-AzureStorageAccountKey
70+
* Get-AzureStorageAccountKey
71+
* Made Azure Storage data cmdlets work in AzureResourceManager Mode
6372

6473
2015.04.28 version 0.8.17
6574
* Azure Batch

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestGetAzureStorageAccount.json

Lines changed: 242 additions & 115 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestGetAzureStorageAccountKey.json

Lines changed: 153 additions & 137 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestNewAzureStorageAccount.json

Lines changed: 172 additions & 105 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestNewAzureStorageAccountKey.json

Lines changed: 229 additions & 147 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestPipingGetAccountToGetKey.json

Lines changed: 167 additions & 256 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestRemoveAzureStorageAccount.json

Lines changed: 174 additions & 107 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestSetAzureStorageAccount.json

Lines changed: 399 additions & 150 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StorageAccountTests/TestStorageAccount.json

Lines changed: 537 additions & 209 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachine.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,58 @@
13611361
},
13621362
"StatusCode": 200
13631363
},
1364+
{
1365+
"RequestUri": "/subscriptions/a0d901ba-9956-4f7d-830c-2d7974c36666/resourceGroups/pstestrg5501/providers/Microsoft.Storage/storageAccounts/stopstestrg5501?api-version=2015-05-01-preview",
1366+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYTBkOTAxYmEtOTk1Ni00ZjdkLTgzMGMtMmQ3OTc0YzM2NjY2L3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnNTUwMS9wcm92aWRlcnMvTWljcm9zb2Z0LlN0b3JhZ2Uvc3RvcmFnZUFjY291bnRzL3N0b3BzdGVzdHJnNTUwMT9hcGktdmVyc2lvbj0yMDE1LTA1LTAxLXByZXZpZXc=",
1367+
"RequestMethod": "GET",
1368+
"RequestBody": "",
1369+
"RequestHeaders": {
1370+
"User-Agent": [
1371+
"Microsoft.Azure.Management.Storage.StorageManagementClient/2.0.0.0"
1372+
]
1373+
},
1374+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/a0d901ba-9956-4f7d-830c-2d7974c36666/resourceGroups/pstestrg5501/providers/Microsoft.Storage/storageAccounts/stopstestrg5501\",\r\n \"name\": \"stopstestrg5501\",\r\n \"location\": \"West US\",\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"accountType\": \"Standard_GRS\",\r\n \"primaryEndpoints\": {\r\n \"blob\": \"https://stopstestrg5501.blob.core.windows.net/\",\r\n \"queue\": \"https://stopstestrg5501.queue.core.windows.net/\",\r\n \"table\": \"https://stopstestrg5501.table.core.windows.net/\"\r\n },\r\n \"primaryLocation\": \"West US\",\r\n \"statusOfPrimary\": \"Available\",\r\n \"secondaryLocation\": \"East US\",\r\n \"statusOfSecondary\": \"Available\",\r\n \"creationTime\": \"2015-04-14T11:12:55.0321932Z\"\r\n }\r\n}",
1375+
"ResponseHeaders": {
1376+
"Content-Length": [
1377+
"672"
1378+
],
1379+
"Content-Type": [
1380+
"application/json; charset=utf-8"
1381+
],
1382+
"Expires": [
1383+
"-1"
1384+
],
1385+
"Pragma": [
1386+
"no-cache"
1387+
],
1388+
"x-ms-request-id": [
1389+
"4e09a47e-87ec-4266-872e-f28a35e47955"
1390+
],
1391+
"Cache-Control": [
1392+
"no-cache"
1393+
],
1394+
"Server": [
1395+
"Microsoft-HTTPAPI/2.0",
1396+
"Microsoft-HTTPAPI/2.0"
1397+
],
1398+
"x-ms-ratelimit-remaining-subscription-reads": [
1399+
"31997"
1400+
],
1401+
"x-ms-correlation-request-id": [
1402+
"7168fe54-cea4-418a-b73b-5f5e6019bfc0"
1403+
],
1404+
"x-ms-routing-request-id": [
1405+
"JAPANWEST:20150414T111324Z:7168fe54-cea4-418a-b73b-5f5e6019bfc0"
1406+
],
1407+
"Strict-Transport-Security": [
1408+
"max-age=31536000; includeSubDomains"
1409+
],
1410+
"Date": [
1411+
"Tue, 14 Apr 2015 11:13:23 GMT"
1412+
]
1413+
},
1414+
"StatusCode": 200
1415+
},
13641416
{
13651417
"RequestUri": "/subscriptions/a0d901ba-9956-4f7d-830c-2d7974c36666/resourceGroups/pstestrg5501/providers/Microsoft.Compute/virtualMachines/vmpstestrg5501?api-version=2015-05-01-preview",
13661418
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYTBkOTAxYmEtOTk1Ni00ZjdkLTgzMGMtMmQ3OTc0YzM2NjY2L3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnNTUwMS9wcm92aWRlcnMvTWljcm9zb2Z0LkNvbXB1dGUvdmlydHVhbE1hY2hpbmVzL3ZtcHN0ZXN0cmc1NTAxP2FwaS12ZXJzaW9uPTIwMTUtMDUtMDEtcHJldmlldw==",

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachineSizeAndUsage.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,61 @@
14801480
},
14811481
"StatusCode": 200
14821482
},
1483+
{
1484+
"RequestUri": "/subscriptions/015b5c33-7725-4fc2-9c81-c9b07de44668/resourceGroups/pstestrg5803/providers/Microsoft.Storage/storageAccounts/stopstestrg5803?api-version=2015-05-01-preview",
1485+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDE1YjVjMzMtNzcyNS00ZmMyLTljODEtYzliMDdkZTQ0NjY4L3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnNTgwMy9wcm92aWRlcnMvTWljcm9zb2Z0LlN0b3JhZ2Uvc3RvcmFnZUFjY291bnRzL3N0b3BzdGVzdHJnNTgwMz9hcGktdmVyc2lvbj0yMDE1LTA1LTAxLXByZXZpZXc=",
1486+
"RequestMethod": "GET",
1487+
"RequestBody": "",
1488+
"RequestHeaders": {
1489+
"x-ms-client-request-id": [
1490+
"c226c2cd-e585-4077-b226-c78722cdef11"
1491+
],
1492+
"User-Agent": [
1493+
"Microsoft.Azure.Management.Storage.StorageManagementClient/2.0.0.0"
1494+
]
1495+
},
1496+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/015b5c33-7725-4fc2-9c81-c9b07de44668/resourceGroups/pstestrg5803/providers/Microsoft.Storage/storageAccounts/stopstestrg5803\",\r\n \"name\": \"stopstestrg5803\",\r\n \"location\": \"West US\",\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"accountType\": \"Standard_GRS\",\r\n \"primaryEndpoints\": {\r\n \"blob\": \"https://stopstestrg5803.blob.core.windows.net/\",\r\n \"queue\": \"https://stopstestrg5803.queue.core.windows.net/\",\r\n \"table\": \"https://stopstestrg5803.table.core.windows.net/\"\r\n },\r\n \"primaryLocation\": \"West US\",\r\n \"statusOfPrimary\": \"Available\",\r\n \"secondaryLocation\": \"East US\",\r\n \"statusOfSecondary\": \"Available\",\r\n \"creationTime\": \"2015-04-15T09:31:54.3552074Z\"\r\n }\r\n}",
1497+
"ResponseHeaders": {
1498+
"Content-Length": [
1499+
"672"
1500+
],
1501+
"Content-Type": [
1502+
"application/json; charset=utf-8"
1503+
],
1504+
"Expires": [
1505+
"-1"
1506+
],
1507+
"Pragma": [
1508+
"no-cache"
1509+
],
1510+
"x-ms-request-id": [
1511+
"34e52591-d98b-4683-8cd0-38b3ff19897a"
1512+
],
1513+
"Cache-Control": [
1514+
"no-cache"
1515+
],
1516+
"Server": [
1517+
"Microsoft-HTTPAPI/2.0",
1518+
"Microsoft-HTTPAPI/2.0"
1519+
],
1520+
"x-ms-ratelimit-remaining-subscription-reads": [
1521+
"31870"
1522+
],
1523+
"x-ms-correlation-request-id": [
1524+
"cf93aa5d-dd8e-4c8f-bd3c-c00c81d250fa"
1525+
],
1526+
"x-ms-routing-request-id": [
1527+
"SOUTHCENTRALUS:20150415T093221Z:cf93aa5d-dd8e-4c8f-bd3c-c00c81d250fa"
1528+
],
1529+
"Strict-Transport-Security": [
1530+
"max-age=31536000; includeSubDomains"
1531+
],
1532+
"Date": [
1533+
"Wed, 15 Apr 2015 09:32:20 GMT"
1534+
]
1535+
},
1536+
"StatusCode": 200
1537+
},
14831538
{
14841539
"RequestUri": "/subscriptions/015b5c33-7725-4fc2-9c81-c9b07de44668/resourceGroups/pstestrg5803/providers/Microsoft.Compute/virtualMachines/vmpstestrg5803?api-version=2015-05-01-preview",
14851540
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDE1YjVjMzMtNzcyNS00ZmMyLTljODEtYzliMDdkZTQ0NjY4L3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnNTgwMy9wcm92aWRlcnMvTWljcm9zb2Z0LkNvbXB1dGUvdmlydHVhbE1hY2hpbmVzL3ZtcHN0ZXN0cmc1ODAzP2FwaS12ZXJzaW9uPTIwMTUtMDUtMDEtcHJldmlldw==",

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<Compile Include="Extension\SetAzureVMExtensionCommand.cs" />
152152
<Compile Include="Extension\RemoveAzureVMExtensionCommand.cs" />
153153
<Compile Include="Extension\GetAzureVMExtensionCommand.cs" />
154+
<Compile Include="Models\PSStorageAccount.cs" />
154155
<Compile Include="Extension\VMAccess\GetAzureVMAccessExtension.cs" />
155156
<Compile Include="Extension\VMAccess\RemoveAzureVMAccessExtension.cs" />
156157
<Compile Include="Extension\VMAccess\SetAzureVMAccessExtension.cs" />
@@ -284,4 +285,4 @@
284285
<Target Name="AfterBuild">
285286
</Target>
286287
-->
287-
</Project>
288+
</Project>

src/ResourceManager/Compute/Commands.Compute/Microsoft.Azure.Commands.Compute.dll-Help.xml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,12 @@
511511
</command:details>
512512
<maml:description>
513513
<!--This is the Description section-->
514-
<maml:para>This cmdlet allows you to get the properties of a specified Storage Account or all Storage Accounts within a Resource Group</maml:para>
514+
<maml:para>This cmdlet allows you to get the properties of a specified Storage Account or all Storage Accounts within a Resource Group or the subscription.</maml:para>
515515
</maml:description>
516516
<command:syntax>
517517
<command:syntaxItem>
518518
<maml:name>Get-AzureStorageAccount</maml:name>
519-
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
519+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
520520
<maml:name>ResourceGroupName</maml:name>
521521
<maml:description>
522522
<maml:para>Name of the Resource Group</maml:para>
@@ -533,7 +533,7 @@
533533
</command:syntaxItem>
534534
</command:syntax>
535535
<command:parameters>
536-
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
536+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
537537
<maml:name>ResourceGroupName</maml:name>
538538
<maml:description>
539539
<maml:para>Name of the Resource Group</maml:para>
@@ -623,6 +623,25 @@
623623
</command:commandLine>
624624
</command:commandLines>
625625
</command:example>
626+
<command:example>
627+
<maml:title>-------------------------- Get all Storage Accounts in the subscription --------------------------</maml:title>
628+
<maml:introduction>
629+
<maml:para></maml:para>
630+
</maml:introduction>
631+
<dev:code>PS C:\&gt; # Get all Storage Accounts in the subscription
632+
Get-AzureStorageAccount</dev:code>
633+
<dev:remarks>
634+
<maml:para />
635+
<maml:para />
636+
<maml:para />
637+
<maml:para></maml:para>
638+
</dev:remarks>
639+
<command:commandLines>
640+
<command:commandLine>
641+
<command:commandText></command:commandText>
642+
</command:commandLine>
643+
</command:commandLines>
644+
</command:example>
626645
</command:examples>
627646
<maml:relatedLinks>
628647
</maml:relatedLinks>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Microsoft.Azure.Management.Storage.Models;
7+
8+
namespace Microsoft.Azure.Commands.Compute.Models
9+
{
10+
class PSStorageAccount
11+
{
12+
public PSStorageAccount(StorageAccount storageAccount)
13+
{
14+
this.ResourceGroupName = ParseResourceGroupFromId(storageAccount.Id);
15+
this.Name = storageAccount.Name;
16+
this.Id = storageAccount.Id;
17+
this.Location = storageAccount.Location;
18+
this.AccountType = storageAccount.AccountType;
19+
this.CreationTime = storageAccount.CreationTime;
20+
this.CustomDomain = storageAccount.CustomDomain;
21+
this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime;
22+
this.PrimaryEndpoints = storageAccount.PrimaryEndpoints;
23+
this.PrimaryLocation = storageAccount.PrimaryLocation;
24+
this.ProvisioningState = storageAccount.ProvisioningState;
25+
this.SecondaryEndpoints = storageAccount.SecondaryEndpoints;
26+
this.SecondaryLocation = storageAccount.SecondaryLocation;
27+
this.StatusOfPrimary = storageAccount.StatusOfPrimary;
28+
this.StatusOfSecondary = storageAccount.StatusOfSecondary;
29+
this.Tags = storageAccount.Tags;
30+
}
31+
32+
public string ResourceGroupName { get; set; }
33+
34+
public string Name { get; set; }
35+
36+
public string Id { get; set; }
37+
38+
public string Location { get; set; }
39+
40+
public AccountType? AccountType { get; set; }
41+
42+
public DateTime? CreationTime { get; set; }
43+
44+
public CustomDomain CustomDomain { get; set; }
45+
46+
public DateTime? LastGeoFailoverTime { get; set; }
47+
48+
public Endpoints PrimaryEndpoints { get; set; }
49+
50+
public string PrimaryLocation { get; set; }
51+
52+
public ProvisioningState? ProvisioningState { get; set; }
53+
54+
public Endpoints SecondaryEndpoints { get; set; }
55+
56+
public string SecondaryLocation { get; set; }
57+
58+
public AccountStatus? StatusOfPrimary { get; set; }
59+
60+
public AccountStatus? StatusOfSecondary { get; set; }
61+
62+
public IDictionary<string, string> Tags { get; set; }
63+
64+
private static string ParseResourceGroupFromId(string idFromServer)
65+
{
66+
if (!string.IsNullOrEmpty(idFromServer))
67+
{
68+
string[] tokens = idFromServer.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
69+
70+
return tokens[3];
71+
}
72+
73+
return null;
74+
}
75+
}
76+
}

src/ResourceManager/Compute/Commands.Compute/StorageAccount/GetAzureStorageAccount.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class GetAzureStorageAccountCommand : StorageAccountBaseCmdlet
2323
{
2424
[Parameter(
2525
Position = 0,
26-
Mandatory = true,
26+
Mandatory = false,
2727
ValueFromPipelineByPropertyName = true,
2828
HelpMessage = "Storage Account Name.")]
2929
[ValidateNotNullOrEmpty]
@@ -42,19 +42,25 @@ public override void ExecuteCmdlet()
4242
{
4343
base.ExecuteCmdlet();
4444

45-
if (string.IsNullOrEmpty(this.Name))
45+
if (string.IsNullOrEmpty(this.ResourceGroupName))
46+
{
47+
var listResponse = this.StorageClient.StorageAccounts.List();
48+
49+
WriteStorageAccountList(listResponse.StorageAccounts);
50+
}
51+
else if (string.IsNullOrEmpty(this.Name))
4652
{
4753
var listResponse = this.StorageClient.StorageAccounts.ListByResourceGroup(this.ResourceGroupName);
4854

49-
WriteObject(listResponse.StorageAccounts, true);
55+
WriteStorageAccountList(listResponse.StorageAccounts);
5056
}
5157
else
5258
{
5359
var getResponse = this.StorageClient.StorageAccounts.GetProperties(
5460
this.ResourceGroupName,
5561
this.Name);
5662

57-
WriteObject(getResponse.StorageAccount);
63+
WriteStorageAccount(getResponse.StorageAccount);
5864
}
5965
}
6066
}

src/ResourceManager/Compute/Commands.Compute/StorageAccount/NewAzureStorageAccount.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public override void ExecuteCmdlet()
7575
this.Name,
7676
createParameters);
7777

78-
WriteObject(createAccountResponse.StorageAccount);
78+
var getAccountResponse = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
79+
80+
this.WriteStorageAccount(getAccountResponse.StorageAccount);
7981
}
8082
}
8183
}

src/ResourceManager/Compute/Commands.Compute/StorageAccount/SetAzureStorageAccount.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public override void ExecuteCmdlet()
128128
this.Name,
129129
updateParameters);
130130

131-
WriteObject(updatedAccountResponse.StorageAccount);
131+
var accountProperties = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
132+
133+
WriteStorageAccount(accountProperties.StorageAccount);
132134
}
133135
}
134136
}

src/ResourceManager/Compute/Commands.Compute/StorageAccount/StorageAccountBaseCmdlet.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using Microsoft.Azure.Commands.Compute.Models;
1619
using Microsoft.Azure.Management.Storage;
1720
using Microsoft.Azure.Management.Storage.Models;
1821
using Microsoft.WindowsAzure.Commands.Utilities.Common;
@@ -97,5 +100,17 @@ protected static AccountType ParseAccountType(string accountType)
97100
}
98101
throw new ArgumentOutOfRangeException("accountType");
99102
}
103+
104+
protected void WriteStorageAccount(StorageAccount storageAccount)
105+
{
106+
WriteObject(new PSStorageAccount(storageAccount));
107+
}
108+
109+
protected void WriteStorageAccountList(IList<StorageAccount> storageAccounts)
110+
{
111+
List<PSStorageAccount> output = new List<PSStorageAccount>();
112+
storageAccounts.ForEach(storageAccount => output.Add(new PSStorageAccount(storageAccount)));
113+
WriteObject(output, true);
114+
}
100115
}
101116
}

0 commit comments

Comments
 (0)