Skip to content

Commit e147e64

Browse files
committed
Allow corre4ct parsing of storage enums
1 parent 8d1a975 commit e147e64

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ 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-
[Microsoft.Azure.Management.Storage.Models.AccountType] [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-
if ($Type -eq $null)
37+
if ($typeString -eq $null)
3838
{
3939
$Type = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS
4040
}
41+
else
42+
{
43+
$Type = Parse-Type $typeString
44+
}
4145

4246
$createParms.AccountType = $Type
4347
$createParms.Location = $Location
@@ -118,6 +122,14 @@ function Get-Context
118122
return $context
119123
}
120124

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+
121133
function Get-StorageClient
122134
{
123135
param([Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext] $context)

0 commit comments

Comments
 (0)