Skip to content

Commit 1dce471

Browse files
committed
Changing identity parameter to a switch parameter
1 parent f658ab2 commit 1dce471

File tree

5 files changed

+43
-44
lines changed

5 files changed

+43
-44
lines changed

src/ResourceManager/Storage/Commands.Management.Storage.Test/ScenarioTests/StorageAccountTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ function Test-SetAzureRmStorageAccountKeySource
310310
Assert-AreEqual $sto.Encryption.Keyvaultproperties.KeyVersion $null;
311311
Assert-AreEqual $sto.Encryption.Keyvaultproperties.KeyVaultUri $null;
312312

313-
$sto = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -EnableEncryptionService File -IdentityType SystemAssigned
313+
$sto = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -EnableEncryptionService File -AssignIdentity
314314
Assert-AreEqual $sto.StorageAccountName $stoname;
315315
Assert-AreEqual $sto.Sku.Name $stotype;
316316
Assert-AreEqual $sto.Location $loc;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ public bool EnableHttpsTrafficOnly
122122

123123
[Parameter(
124124
Mandatory = false,
125-
HelpMessage = "Storage Account Identity Type.")]
126-
[ValidateSet("SystemAssigned", IgnoreCase = true)]
127-
public string IdentityType { get; set; }
125+
HelpMessage = "Generate and assign a new Storage Account Identity for this storage account for use with key management services like Azure KeyVault.")]
126+
public SwitchParameter AssignIdentity { get; set; }
128127

129128
public override void ExecuteCmdlet()
130129
{
@@ -176,7 +175,7 @@ public override void ExecuteCmdlet()
176175
createParameters.EnableHttpsTrafficOnly = enableHttpsTrafficOnly;
177176
}
178177

179-
if (IdentityType != null)
178+
if (AssignIdentity.IsPresent)
180179
{
181180
createParameters.Identity = new Identity();
182181
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ public string KeyVaultUri
175175

176176
[Parameter(
177177
Mandatory = false,
178-
HelpMessage = "Storage Account Identity Type.")]
179-
[ValidateSet("SystemAssigned",IgnoreCase = true)]
180-
public string IdentityType { get; set; }
178+
HelpMessage = "Generate and assign a new Storage Account Identity for this storage account for use with key management services like Azure KeyVault.")]
179+
public SwitchParameter AssignIdentity { get; set; }
181180

182181
public override void ExecuteCmdlet()
183182
{
@@ -221,7 +220,7 @@ public override void ExecuteCmdlet()
221220
updateParameters.EnableHttpsTrafficOnly = enableHttpsTrafficOnly;
222221
}
223222

224-
if (IdentityType != null)
223+
if (AssignIdentity.IsPresent)
225224
{
226225
updateParameters.Identity = new Identity();
227226
}

src/ResourceManager/Storage/Commands.Management.Storage/help/New-AzureRmStorageAccount.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Creates a Storage account.
1616
New-AzureRmStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <String>
1717
[-Location] <String> [[-Kind] <String>] [[-AccessTier] <String>] [[-CustomDomainName] <String>]
1818
[[-UseSubDomain] <Boolean>] [[-EnableEncryptionService] <EncryptionSupportServiceEnum>] [[-Tag] <Hashtable>]
19-
[-EnableHttpsTrafficOnly <Boolean>] [-IdentityType <String>] [-InformationAction <ActionPreference>]
19+
[-EnableHttpsTrafficOnly <Boolean>] [-AssignIdentity] [-InformationAction <ActionPreference>]
2020
[-InformationVariable <String>] [<CommonParameters>]
2121
```
2222

@@ -25,27 +25,28 @@ The **New-AzureRmStorageAccount** cmdlet creates an Azure Storage account.
2525

2626
## EXAMPLES
2727

28-
### Example 1: Create a Storage account
28+
### Example 1: Create a Storage Account
2929
```
3030
PS C:\>New-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -Location "US West" -Type "Standard_GRS"
3131
```
3232

3333
This command creates a Storage account for the resource group name MyResourceGroup.
3434

35-
### Example 2: Create a bBlob Storage account that uses Storage Service encryptionB
35+
### Example 2: Create a Blob Storage account that uses Storage Service Encryption
3636
```
3737
PS C:\>New-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -Location "US West" -SkuName "Standard_GRS" -EnableEncryptionService Blob -Kind "BlobStorage" -AccessTier Hot
3838
```
3939

4040
This command creates a Blob Storage account that uses the hot access type.
4141
The account has enabled Storage Service encryption on Blob Service.
4242

43-
### Example 3: Create a Storage account that Enable Storage Service encryption on Blob and File Services, and set IdentityType to SystemAssigned.
43+
### Example 3: Create a Storage Account that Enables Storage Service Encryption on Blob and File Services, and Generate and Assign an Identity for Azure KeyVault.
4444
```
45-
PS C:\>New-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -Location "US West" -SkuName "Standard_GRS" -EnableEncryptionService "Blob,File" -IdentityType SystemAssigned
45+
PS C:\>New-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -Location "US West" -SkuName "Standard_GRS" -EnableEncryptionService "Blob,File" -AssignIdentity
4646
```
4747

48-
This command creates a Storage account that enabled Storage Service encryption on Blob and File Services, IdentityType as SystemAssigned.
48+
This command creates a Storage account that enabled Storage Service encryption on Blob and File Services. It also generates and assigns an identity that can be sued to manage
49+
account keys through Azure KeyVault.
4950

5051
## PARAMETERS
5152

@@ -69,6 +70,19 @@ Accept pipeline input: False
6970
Accept wildcard characters: False
7071
```
7172
73+
### -AssignIdentity
74+
Generate and assign a new Storage Account Identity for this storage account for use with key management services like Azure KeyVault.```yaml
75+
Type: SwitchParameter
76+
Parameter Sets: (All)
77+
Aliases:
78+
79+
Required: False
80+
Position: Named
81+
Default value: None
82+
Accept pipeline input: False
83+
Accept wildcard characters: False
84+
```
85+
7286
### -CustomDomainName
7387
Specifies the name of the custom domain of the Storage account.
7488
The default value is Storage.
@@ -114,19 +128,6 @@ Accept pipeline input: True (ByPropertyName)
114128
Accept wildcard characters: False
115129
```
116130
117-
### -IdentityType
118-
Specifies Storage Account Identity Type. ```yaml
119-
Type: String
120-
Parameter Sets: (All)
121-
Aliases:
122-
123-
Required: False
124-
Position: Named
125-
Default value: None
126-
Accept pipeline input: False
127-
Accept wildcard characters: False
128-
```
129-
130131
### -InformationAction
131132
Specifies how this cmdlet responds to an information event.
132133

src/ResourceManager/Storage/Commands.Management.Storage/help/Set-AzureRmStorageAccount.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Set-AzureRmStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-Force
1818
[[-AccessTier] <String>] [[-CustomDomainName] <String>] [[-UseSubDomain] <Boolean>]
1919
[[-EnableEncryptionService] <EncryptionSupportServiceEnum>]
2020
[[-DisableEncryptionService] <EncryptionSupportServiceEnum>] [[-Tag] <Hashtable>]
21-
[-EnableHttpsTrafficOnly <Boolean>] [-StorageEncryption] [-IdentityType <String>]
21+
[-EnableHttpsTrafficOnly <Boolean>] [-StorageEncryption] [-AssignIdentity]
2222
[-InformationAction <ActionPreference>] [-InformationVariable <String>] [-WhatIf] [-Confirm]
2323
[<CommonParameters>]
2424
```
@@ -30,7 +30,7 @@ Set-AzureRmStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-Force
3030
[[-EnableEncryptionService] <EncryptionSupportServiceEnum>]
3131
[[-DisableEncryptionService] <EncryptionSupportServiceEnum>] [[-Tag] <Hashtable>]
3232
[-EnableHttpsTrafficOnly <Boolean>] [-KeyvaultEncryption] -KeyName <String> -KeyVersion <String>
33-
-KeyVaultUri <String> [-IdentityType <String>] [-InformationAction <ActionPreference>]
33+
-KeyVaultUri <String> [-AssignIdentity] [-InformationAction <ActionPreference>]
3434
[-InformationVariable <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
3535
```
3636

@@ -77,7 +77,7 @@ The command sets the Access Tier value to be cool.
7777

7878
### Example 5: Enable encryption on Blob Services with Keyvault
7979
```
80-
PS C:\>Set-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -IdentityType SystemAssigned
80+
PS C:\>Set-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -AssignIdentity
8181
PS C:\>$account = Get-AzureRmStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount"
8282
8383
PS C:\>$keyVault = New-AzureRmKeyVault -VaultName "MyKeyVault" -ResourceGroupName "MyResourceGroup" -Location "EastUS2"
@@ -118,6 +118,19 @@ Accept pipeline input: False
118118
Accept wildcard characters: False
119119
```
120120
121+
### -AssignIdentity
122+
Generate and assign a new Storage Account Identity for this storage account for use with key management services like Azure KeyVault.```yaml
123+
Type: SwitchParameter
124+
Parameter Sets: (All)
125+
Aliases:
126+
127+
Required: False
128+
Position: Named
129+
Default value: None
130+
Accept pipeline input: False
131+
Accept wildcard characters: False
132+
```
133+
121134
### -CustomDomainName
122135
Specifies the name of the custom domain.
123136
@@ -195,19 +208,6 @@ Accept pipeline input: False
195208
Accept wildcard characters: False
196209
```
197210
198-
### -IdentityType
199-
Specifies Storage Account Identity Type.```yaml
200-
Type: String
201-
Parameter Sets: (All)
202-
Aliases:
203-
204-
Required: False
205-
Position: Named
206-
Default value: None
207-
Accept pipeline input: False
208-
Accept wildcard characters: False
209-
```
210-
211211
### -InformationAction
212212
Specifies how this cmdlet responds to an information event.
213213

0 commit comments

Comments
 (0)