Skip to content

Commit 07f48a6

Browse files
authored
[Az.KeyVault] Supports overriding default subscription via -SubscriptionId (Azure#15795)
1 parent d1921a2 commit 07f48a6

26 files changed

+416
-81
lines changed

src/KeyVault/KeyVault/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Enabled managing resources in other subscriptions without switching the context by adding `-Subscription <String>`.
2122
* Supported adding EC keys in key vault [#15699]
2223

2324
## Version 3.4.5

src/KeyVault/KeyVault/Models/KeyVaultManagementCmdletBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
3636
using SecretPerms = Microsoft.Azure.Management.KeyVault.Models.SecretPermissions;
3737
using StoragePerms = Microsoft.Azure.Management.KeyVault.Models.StoragePermissions;
38+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
3839

3940
namespace Microsoft.Azure.Commands.KeyVault
4041
{
42+
[SupportsSubscriptionId]
4143
public class KeyVaultManagementCmdletBase : AzureRMCmdlet
4244
{
4345

src/KeyVault/KeyVault/SecurityDomain/Cmdlets/SecurityDomainCmdlet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using Microsoft.Azure.Commands.KeyVault.Models;
33
using Microsoft.Azure.Commands.KeyVault.SecurityDomain.Models;
44
using Microsoft.Azure.Commands.ResourceManager.Common;
5+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
56
using Microsoft.WindowsAzure.Commands.Utilities.Common;
67
using System.Management.Automation;
78
using System.Threading;
89

910
namespace Microsoft.Azure.Commands.KeyVault.SecurityDomain.Cmdlets
1011
{
12+
[SupportsSubscriptionId]
1113
public abstract class SecurityDomainCmdlet : AzureRMCmdlet
1214
{
1315
protected const string ByName = "ByName";

src/KeyVault/KeyVault/help/Add-AzKeyVaultNetworkRule.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ Adds a rule meant to restrict access to a key vault based on the client's intern
1616
```
1717
Add-AzKeyVaultNetworkRule [-VaultName] <String> [[-ResourceGroupName] <String>] [-IpAddressRange <String[]>]
1818
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
19-
[-Confirm] [<CommonParameters>]
19+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
2020
```
2121

2222
### ByInputObject
2323
```
2424
Add-AzKeyVaultNetworkRule [-InputObject] <PSKeyVault> [-IpAddressRange <String[]>]
2525
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
26-
[-Confirm] [<CommonParameters>]
26+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
2727
```
2828

2929
### ByResourceId
3030
```
3131
Add-AzKeyVaultNetworkRule [-ResourceId] <String> [-IpAddressRange <String[]>]
3232
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
33-
[-Confirm] [<CommonParameters>]
33+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
3434
```
3535

3636
## DESCRIPTION
@@ -181,6 +181,23 @@ Accept pipeline input: True (ByPropertyName)
181181
Accept wildcard characters: False
182182
```
183183
184+
### -SubscriptionId
185+
The ID of the subscription.
186+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
187+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
188+
189+
```yaml
190+
Type: System.String
191+
Parameter Sets: (All)
192+
Aliases:
193+
194+
Required: False
195+
Position: Named
196+
Default value: None
197+
Accept pipeline input: True (ByPropertyName)
198+
Accept wildcard characters: False
199+
```
200+
184201
### -VaultName
185202
Specifies the name of a key vault whose network rule is being modified.
186203

src/KeyVault/KeyVault/help/Az.KeyVault.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Gets the status of a certificate operation.
6363
Gets the policy for a certificate in a key vault.
6464

6565
### [Get-AzKeyVaultKey](Get-AzKeyVaultKey.md)
66-
Gets Key Vault keys.
66+
Gets Key Vault keys. Please notes that detailed information about a key, like key type or key size, only available when querying a key in a certain version.
6767

6868
### [Get-AzKeyVaultManagedHsm](Get-AzKeyVaultManagedHsm.md)
6969
Get managed HSMs.

src/KeyVault/KeyVault/help/Export-AzKeyVaultSecurityDomain.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Exports the security domain data of a managed HSM.
1616
```
1717
Export-AzKeyVaultSecurityDomain -Certificates <String[]> -OutputPath <String> [-Force] [-PassThru]
1818
-Quorum <Int32> -Name <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
19-
[<CommonParameters>]
19+
[-SubscriptionId <String>] [<CommonParameters>]
2020
```
2121

2222
### ByInputObject
2323
```
2424
Export-AzKeyVaultSecurityDomain -Certificates <String[]> -OutputPath <String> [-Force] [-PassThru]
2525
-Quorum <Int32> -InputObject <PSKeyVaultIdentityItem> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
26-
[-Confirm] [<CommonParameters>]
26+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
2727
```
2828

2929
## DESCRIPTION
@@ -160,6 +160,23 @@ Accept pipeline input: False
160160
Accept wildcard characters: False
161161
```
162162
163+
### -SubscriptionId
164+
The ID of the subscription.
165+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
166+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
167+
168+
```yaml
169+
Type: System.String
170+
Parameter Sets: (All)
171+
Aliases:
172+
173+
Required: False
174+
Position: Named
175+
Default value: None
176+
Accept pipeline input: True (ByPropertyName)
177+
Accept wildcard characters: False
178+
```
179+
163180
### -Confirm
164181
Prompts you for confirmation before running the cmdlet.
165182

src/KeyVault/KeyVault/help/Get-AzKeyVault.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ Gets key vaults.
1616
### GetVaultByName (Default)
1717
```
1818
Get-AzKeyVault [[-VaultName] <String>] [[-ResourceGroupName] <String>] [-Tag <Hashtable>]
19-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
19+
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
2020
```
2121

2222
### ByDeletedVault
2323
```
2424
Get-AzKeyVault [-VaultName] <String> [-Location] <String> [-InRemovedState]
25-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
25+
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
2626
```
2727

2828
### ListAllDeletedVaultsInSubscription
2929
```
30-
Get-AzKeyVault [-InRemovedState] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
30+
Get-AzKeyVault [-InRemovedState] [-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>]
31+
[<CommonParameters>]
3132
```
3233

3334
## DESCRIPTION
@@ -240,7 +241,24 @@ Required: False
240241
Position: 1
241242
Default value: None
242243
Accept pipeline input: True (ByPropertyName)
243-
Accept wildcard characters: True
244+
Accept wildcard characters: False
245+
```
246+
247+
### -SubscriptionId
248+
The ID of the subscription.
249+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
250+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
251+
252+
```yaml
253+
Type: System.String
254+
Parameter Sets: (All)
255+
Aliases:
256+
257+
Required: False
258+
Position: Named
259+
Default value: None
260+
Accept pipeline input: True (ByPropertyName)
261+
Accept wildcard characters: False
244262
```
245263
246264
### -Tag
@@ -271,7 +289,7 @@ Required: False
271289
Position: 0
272290
Default value: None
273291
Accept pipeline input: True (ByPropertyName)
274-
Accept wildcard characters: True
292+
Accept wildcard characters: False
275293
```
276294
277295
```yaml
@@ -283,7 +301,7 @@ Required: True
283301
Position: 0
284302
Default value: None
285303
Accept pipeline input: True (ByPropertyName)
286-
Accept wildcard characters: True
304+
Accept wildcard characters: False
287305
```
288306
289307
### CommonParameters

src/KeyVault/KeyVault/help/Get-AzKeyVaultCertificate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Required: False
307307
Position: 1
308308
Default value: None
309309
Accept pipeline input: False
310-
Accept wildcard characters: True
310+
Accept wildcard characters: False
311311
```
312312
313313
```yaml
@@ -319,7 +319,7 @@ Required: True
319319
Position: 1
320320
Default value: None
321321
Accept pipeline input: False
322-
Accept wildcard characters: True
322+
Accept wildcard characters: False
323323
```
324324
325325
### -ResourceId

src/KeyVault/KeyVault/help/Get-AzKeyVaultCertificateIssuer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Required: False
115115
Position: 1
116116
Default value: None
117117
Accept pipeline input: False
118-
Accept wildcard characters: True
118+
Accept wildcard characters: False
119119
```
120120
121121
### -ResourceId

src/KeyVault/KeyVault/help/Get-AzKeyVaultKey.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Required: False
435435
Position: 1
436436
Default value: None
437437
Accept pipeline input: False
438-
Accept wildcard characters: True
438+
Accept wildcard characters: False
439439
```
440440
441441
```yaml
@@ -447,7 +447,7 @@ Required: True
447447
Position: 1
448448
Default value: None
449449
Accept pipeline input: False
450-
Accept wildcard characters: True
450+
Accept wildcard characters: False
451451
```
452452
453453
### -OutFile

src/KeyVault/KeyVault/help/Get-AzKeyVaultManagedHsm.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Get managed HSMs.
1414

1515
```
1616
Get-AzKeyVaultManagedHsm [[-Name] <String>] [[-ResourceGroupName] <String>] [-Tag <Hashtable>]
17-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
1818
```
1919

2020
## DESCRIPTION
@@ -99,7 +99,7 @@ Required: False
9999
Position: 0
100100
Default value: None
101101
Accept pipeline input: True (ByPropertyName)
102-
Accept wildcard characters: True
102+
Accept wildcard characters: False
103103
```
104104
105105
### -ResourceGroupName
@@ -114,7 +114,24 @@ Required: False
114114
Position: 1
115115
Default value: None
116116
Accept pipeline input: True (ByPropertyName)
117-
Accept wildcard characters: True
117+
Accept wildcard characters: False
118+
```
119+
120+
### -SubscriptionId
121+
The ID of the subscription.
122+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
123+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
124+
125+
```yaml
126+
Type: System.String
127+
Parameter Sets: (All)
128+
Aliases:
129+
130+
Required: False
131+
Position: Named
132+
Default value: None
133+
Accept pipeline input: True (ByPropertyName)
134+
Accept wildcard characters: False
118135
```
119136
120137
### -Tag

src/KeyVault/KeyVault/help/Get-AzKeyVaultManagedStorageAccount.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Required: False
113113
Position: 1
114114
Default value: None
115115
Accept pipeline input: False
116-
Accept wildcard characters: True
116+
Accept wildcard characters: False
117117
```
118118
119119
### -DefaultProfile

src/KeyVault/KeyVault/help/Get-AzKeyVaultSecret.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Required: False
360360
Position: 1
361361
Default value: None
362362
Accept pipeline input: False
363-
Accept wildcard characters: True
363+
Accept wildcard characters: False
364364
```
365365
366366
```yaml
@@ -372,7 +372,7 @@ Required: True
372372
Position: 1
373373
Default value: None
374374
Accept pipeline input: False
375-
Accept wildcard characters: True
375+
Accept wildcard characters: False
376376
```
377377
378378
### -ResourceId

src/KeyVault/KeyVault/help/Import-AzKeyVaultSecurityDomain.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ Imports previously exported security domain data to a managed HSM.
1515
### ByName (Default)
1616
```
1717
Import-AzKeyVaultSecurityDomain -Keys <KeyPath[]> -SecurityDomainPath <String> [-PassThru] -Name <String>
18-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
18+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
19+
[<CommonParameters>]
1920
```
2021

2122
### ByInputObject
2223
```
2324
Import-AzKeyVaultSecurityDomain -Keys <KeyPath[]> -SecurityDomainPath <String> [-PassThru]
2425
-InputObject <PSKeyVaultIdentityItem> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
25-
[<CommonParameters>]
26+
[-SubscriptionId <String>] [<CommonParameters>]
2627
```
2728

2829
## DESCRIPTION
@@ -132,6 +133,23 @@ Accept pipeline input: False
132133
Accept wildcard characters: False
133134
```
134135
136+
### -SubscriptionId
137+
The ID of the subscription.
138+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
139+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
140+
141+
```yaml
142+
Type: System.String
143+
Parameter Sets: (All)
144+
Aliases:
145+
146+
Required: False
147+
Position: Named
148+
Default value: None
149+
Accept pipeline input: True (ByPropertyName)
150+
Accept wildcard characters: False
151+
```
152+
135153
### -Confirm
136154
Prompts you for confirmation before running the cmdlet.
137155

src/KeyVault/KeyVault/help/New-AzKeyVault.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ New-AzKeyVault [-Name] <String> [-ResourceGroupName] <String> [-Location] <Strin
1818
[-EnabledForTemplateDeployment] [-EnabledForDiskEncryption] [-EnablePurgeProtection]
1919
[-EnableRbacAuthorization] [-SoftDeleteRetentionInDays <Int32>] [-Sku <String>] [-Tag <Hashtable>]
2020
[-NetworkRuleSet <PSKeyVaultNetworkRuleSet>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
21-
[<CommonParameters>]
21+
[-SubscriptionId <String>] [<CommonParameters>]
2222
```
2323

2424
## DESCRIPTION
@@ -301,6 +301,23 @@ Accept pipeline input: False
301301
Accept wildcard characters: False
302302
```
303303

304+
### -SubscriptionId
305+
The ID of the subscription.
306+
By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.
307+
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
308+
309+
```yaml
310+
Type: System.String
311+
Parameter Sets: (All)
312+
Aliases:
313+
314+
Required: False
315+
Position: Named
316+
Default value: None
317+
Accept pipeline input: True (ByPropertyName)
318+
Accept wildcard characters: False
319+
```
320+
304321
### -Tag
305322
Key-value pairs in the form of a hash table. For example:
306323
@{key0="value0";key1=$null;key2="value2"}

0 commit comments

Comments
 (0)