Skip to content

Commit 5081dac

Browse files
committed
Update script storage new-azurermstorageaccount implementation to remove storage account from the output stream
- add remove-azurermstorageaccount cmdlet - Add script into api management tests
1 parent de5e01a commit 5081dac

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@
179179
</ProjectReference>
180180
</ItemGroup>
181181
<ItemGroup>
182+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Storage.ps1">
183+
<Link>ScenarioTests\AzureRM.Storage.ps1</Link>
184+
</None>
182185
<None Include="packages.config">
183186
<SubType>Designer</SubType>
184187
</None>

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ private void RunPowerShellTest(params string[] scripts)
176176
_helper.RMProfileModule,
177177
_helper.RMResourceModule,
178178
_helper.RMStorageDataPlaneModule,
179-
_helper.RMStorageModule,
180-
_helper.GetRMModulePath("AzureRM.ApiManagement.psd1"));
179+
_helper.GetRMModulePath("AzureRM.ApiManagement.psd1"),
180+
"AzureRM.Storage.ps1");
181181

182182
_helper.RunPowerShellTest(scripts);
183183
}

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ function Get-AzureRmStorageAccount
55
[CmdletBinding()]
66
param(
77
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
8-
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] $Name)
8+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
99
BEGIN {
1010
$context = Get-Context
1111
$client = Get-StorageClient $context
1212
}
1313
PROCESS {
1414
$getTask = $client.StorageAccounts.GetPropertiesAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None)
1515
$sa = $getTask.Result
16-
$account = Get-StorageAccount $sa $ResourceGroupName
16+
$account = Get-StorageAccount $ResourceGroupName $Name
1717
Write-Output $account
1818
}
1919
END {}
@@ -25,7 +25,7 @@ function New-AzureRmStorageAccount
2525
[CmdletBinding()]
2626
param(
2727
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
28-
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] $Name,
28+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)][alias("StorageAccountName")] $Name,
2929
[string] [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] $Location,
3030
[string] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $Type)
3131
BEGIN {
@@ -38,8 +38,6 @@ function New-AzureRmStorageAccount
3838
$createParms.Location = $Location
3939
$getTask = $client.StorageAccounts.CreateAsync($ResourceGroupName, $name, $createParms, [System.Threading.CancellationToken]::None)
4040
$sa = $getTask.Result
41-
$account = Get-StorageAccount $ResourceGroupName $Name
42-
Write-Output $account
4341
}
4442
END {}
4543

@@ -50,7 +48,7 @@ function Get-AzureRmStorageAccountKey
5048
[CmdletBinding()]
5149
param(
5250
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
53-
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] $Name)
51+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
5452
BEGIN {
5553
$context = Get-Context
5654
$client = Get-StorageClient $context
@@ -62,6 +60,25 @@ function Get-AzureRmStorageAccountKey
6260
END {}
6361
}
6462

63+
function Remove-AzureRmStorageAccount
64+
{
65+
66+
[CmdletBinding()]
67+
param(
68+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
69+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
70+
BEGIN {
71+
$context = Get-Context
72+
$client = Get-StorageClient $context
73+
}
74+
PROCESS {
75+
$getTask = $client.StorageAccounts.DeleteAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None)
76+
$sa = $getTask.Result
77+
}
78+
END {}
79+
80+
}
81+
6582
function Get-Context
6683
{
6784
[Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext]$context = $null
@@ -88,6 +105,9 @@ function Get-StorageClient
88105

89106
function Get-StorageAccount {
90107
param([string] $resourceGroupName, [string] $name)
91-
$sa = New-Object PSObject -Property @{"Name" = $name; "ResourceGroupName" = $resourceGroupName}
108+
$endpoints = New-Object PSObject -Property @{"Blob" = "https://$name.blob.core.windows.net/"}
109+
$sa = New-Object PSObject -Property @{"Name" = $name; "ResourceGroupName" = $resourceGroupName;
110+
"PrimaryEndpoints" = $endpoints
111+
}
92112
return $sa
93113
}

src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
<Compile Include="Properties\AssemblyInfo.cs" />
153153
</ItemGroup>
154154
<ItemGroup>
155+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Storage.ps1">
156+
<Link>ScenarioTests\AzureRM.Storage.ps1</Link>
157+
</None>
155158
<None Include="MSSharedLibKey.snk" />
156159
<None Include="packages.config">
157160
<SubType>Designer</SubType>
@@ -304,10 +307,6 @@
304307
<Project>{e1f5201d-6067-430e-b303-4e367652991b}</Project>
305308
<Name>Commands.Resources</Name>
306309
</ProjectReference>
307-
<ProjectReference Include="..\..\Storage\Commands.Management.Storage\Commands.Management.Storage.csproj">
308-
<Project>{a50ab133-5c04-4a17-9054-f8343683ec23}</Project>
309-
<Name>Commands.Management.Storage</Name>
310-
</ProjectReference>
311310
<ProjectReference Include="..\Commands.Websites\Commands.Websites.csproj">
312311
<Project>{80a92297-7c92-456b-8ee7-9fb6ce30149d}</Project>
313312
<Name>Commands.Websites</Name>

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public void RunPsTestWorkflow(
117117
"ScenarioTests\\" + callingClassName + ".ps1",
118118
helper.RMProfileModule,
119119
helper.RMStorageDataPlaneModule,
120-
helper.RMStorageModule,
121120
helper.RMResourceModule,
122-
helper.GetRMModulePath(@"AzureRM.WebSites.psd1"));
121+
helper.GetRMModulePath(@"AzureRM.WebSites.psd1"),
122+
"AzureRM.Storage.ps1");
123123

124124
try
125125
{

0 commit comments

Comments
 (0)