Skip to content

Commit 0c40b81

Browse files
author
Hovsep
committed
Merge pull request #2327 from markcowl/storageps1
Adding missing methods to storage script cmdlets
2 parents 038bf95 + e147e64 commit 0c40b81

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ function New-AzureRmStorageAccount
2727
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
2828
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)][alias("StorageAccountName")] $Name,
2929
[string] [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] $Location,
30-
[string] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $Type)
30+
[string] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $typeString)
3131
BEGIN {
3232
$context = Get-Context
3333
$client = Get-StorageClient $context
3434
}
3535
PROCESS {
3636
$createParms = New-Object -Type Microsoft.Azure.Management.Storage.Models.StorageAccountCreateParameters
37-
$createParms.AccountType = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS
37+
if ($typeString -eq $null)
38+
{
39+
$Type = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS
40+
}
41+
else
42+
{
43+
$Type = Parse-Type $typeString
44+
}
45+
46+
$createParms.AccountType = $Type
3847
$createParms.Location = $Location
3948
$getTask = $client.StorageAccounts.CreateAsync($ResourceGroupName, $name, $createParms, [System.Threading.CancellationToken]::None)
4049
$sa = $getTask.Result
@@ -43,6 +52,28 @@ function New-AzureRmStorageAccount
4352

4453
}
4554

55+
function Set-AzureRmStorageAccount
56+
{
57+
[CmdletBinding()]
58+
param(
59+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
60+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)][alias("StorageAccountName")] $Name,
61+
[string] [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] $Type,
62+
[Hashtable[]] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $Tags)
63+
BEGIN {
64+
$context = Get-Context
65+
$client = Get-StorageClient $context
66+
}
67+
PROCESS {
68+
$createParms = New-Object -Type Microsoft.Azure.Management.Storage.Models.StorageAccountUpdateParameters
69+
$createParms.AccountType = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS
70+
$getTask = $client.StorageAccounts.UpdateAsync($ResourceGroupName, $Name, $createParms, [System.Threading.CancellationToken]::None)
71+
$sa = $getTask.Result
72+
}
73+
END {}
74+
}
75+
76+
4677
function Get-AzureRmStorageAccountKey
4778
{
4879
[CmdletBinding()]
@@ -91,6 +122,14 @@ function Get-Context
91122
return $context
92123
}
93124

125+
function Parse-Type
126+
{
127+
param([string] $type)
128+
$type = $type.Replace("_", "")
129+
$returnSkuName = [System.Enum]::Parse([Microsoft.Azure.Management.Storage.Models.AccountType], $type)
130+
return $returnSkuName;
131+
}
132+
94133
function Get-StorageClient
95134
{
96135
param([Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext] $context)

0 commit comments

Comments
 (0)