Skip to content

Commit

Permalink
[Az.KeyVault] Supports overriding default subscription via -Subscript…
Browse files Browse the repository at this point in the history
…ionId (#15795)
  • Loading branch information
BethanyZhou authored Sep 2, 2021
1 parent d1921a2 commit 07f48a6
Show file tree
Hide file tree
Showing 26 changed files with 416 additions and 81 deletions.
1 change: 1 addition & 0 deletions src/KeyVault/KeyVault/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Enabled managing resources in other subscriptions without switching the context by adding `-Subscription <String>`.
* Supported adding EC keys in key vault [#15699]

## Version 3.4.5
Expand Down
2 changes: 2 additions & 0 deletions src/KeyVault/KeyVault/Models/KeyVaultManagementCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
using SecretPerms = Microsoft.Azure.Management.KeyVault.Models.SecretPermissions;
using StoragePerms = Microsoft.Azure.Management.KeyVault.Models.StoragePermissions;
using Microsoft.WindowsAzure.Commands.Common.Attributes;

namespace Microsoft.Azure.Commands.KeyVault
{
[SupportsSubscriptionId]
public class KeyVaultManagementCmdletBase : AzureRMCmdlet
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using Microsoft.Azure.Commands.KeyVault.Models;
using Microsoft.Azure.Commands.KeyVault.SecurityDomain.Models;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Microsoft.WindowsAzure.Commands.Common.Attributes;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System.Management.Automation;
using System.Threading;

namespace Microsoft.Azure.Commands.KeyVault.SecurityDomain.Cmdlets
{
[SupportsSubscriptionId]
public abstract class SecurityDomainCmdlet : AzureRMCmdlet
{
protected const string ByName = "ByName";
Expand Down
23 changes: 20 additions & 3 deletions src/KeyVault/KeyVault/help/Add-AzKeyVaultNetworkRule.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ Adds a rule meant to restrict access to a key vault based on the client's intern
```
Add-AzKeyVaultNetworkRule [-VaultName] <String> [[-ResourceGroupName] <String>] [-IpAddressRange <String[]>]
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

### ByInputObject
```
Add-AzKeyVaultNetworkRule [-InputObject] <PSKeyVault> [-IpAddressRange <String[]>]
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

### ByResourceId
```
Add-AzKeyVaultNetworkRule [-ResourceId] <String> [-IpAddressRange <String[]>]
[-VirtualNetworkResourceId <String[]>] [-PassThru] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -181,6 +181,23 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -SubscriptionId
The ID of the subscription.
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.
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.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -VaultName
Specifies the name of a key vault whose network rule is being modified.
Expand Down
2 changes: 1 addition & 1 deletion src/KeyVault/KeyVault/help/Az.KeyVault.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Gets the status of a certificate operation.
Gets the policy for a certificate in a key vault.

### [Get-AzKeyVaultKey](Get-AzKeyVaultKey.md)
Gets Key Vault keys.
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.

### [Get-AzKeyVaultManagedHsm](Get-AzKeyVaultManagedHsm.md)
Get managed HSMs.
Expand Down
21 changes: 19 additions & 2 deletions src/KeyVault/KeyVault/help/Export-AzKeyVaultSecurityDomain.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Exports the security domain data of a managed HSM.
```
Export-AzKeyVaultSecurityDomain -Certificates <String[]> -OutputPath <String> [-Force] [-PassThru]
-Quorum <Int32> -Name <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-SubscriptionId <String>] [<CommonParameters>]
```

### ByInputObject
```
Export-AzKeyVaultSecurityDomain -Certificates <String[]> -OutputPath <String> [-Force] [-PassThru]
-Quorum <Int32> -InputObject <PSKeyVaultIdentityItem> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -160,6 +160,23 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -SubscriptionId
The ID of the subscription.
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.
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.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
Expand Down
30 changes: 24 additions & 6 deletions src/KeyVault/KeyVault/help/Get-AzKeyVault.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ Gets key vaults.
### GetVaultByName (Default)
```
Get-AzKeyVault [[-VaultName] <String>] [[-ResourceGroupName] <String>] [-Tag <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
```

### ByDeletedVault
```
Get-AzKeyVault [-VaultName] <String> [-Location] <String> [-InRemovedState]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
```

### ListAllDeletedVaultsInSubscription
```
Get-AzKeyVault [-InRemovedState] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Get-AzKeyVault [-InRemovedState] [-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -240,7 +241,24 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Accept wildcard characters: False
```
### -SubscriptionId
The ID of the subscription.
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.
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.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Tag
Expand Down Expand Up @@ -271,7 +289,7 @@ Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Accept wildcard characters: False
```
```yaml
Expand All @@ -283,7 +301,7 @@ Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Accept wildcard characters: False
```
### CommonParameters
Expand Down
4 changes: 2 additions & 2 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultCertificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
```yaml
Expand All @@ -319,7 +319,7 @@ Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
### -ResourceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
### -ResourceId
Expand Down
4 changes: 2 additions & 2 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
```yaml
Expand All @@ -447,7 +447,7 @@ Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
### -OutFile
Expand Down
23 changes: 20 additions & 3 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultManagedHsm.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Get managed HSMs.

```
Get-AzKeyVaultManagedHsm [[-Name] <String>] [[-ResourceGroupName] <String>] [-Tag <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -99,7 +99,7 @@ Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Accept wildcard characters: False
```
### -ResourceGroupName
Expand All @@ -114,7 +114,24 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
Accept wildcard characters: False
```
### -SubscriptionId
The ID of the subscription.
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.
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.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
### -DefaultProfile
Expand Down
4 changes: 2 additions & 2 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
```yaml
Expand All @@ -372,7 +372,7 @@ Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
Accept wildcard characters: False
```
### -ResourceId
Expand Down
22 changes: 20 additions & 2 deletions src/KeyVault/KeyVault/help/Import-AzKeyVaultSecurityDomain.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ Imports previously exported security domain data to a managed HSM.
### ByName (Default)
```
Import-AzKeyVaultSecurityDomain -Keys <KeyPath[]> -SecurityDomainPath <String> [-PassThru] -Name <String>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
```

### ByInputObject
```
Import-AzKeyVaultSecurityDomain -Keys <KeyPath[]> -SecurityDomainPath <String> [-PassThru]
-InputObject <PSKeyVaultIdentityItem> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -132,6 +133,23 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -SubscriptionId
The ID of the subscription.
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.
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.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
Expand Down
19 changes: 18 additions & 1 deletion src/KeyVault/KeyVault/help/New-AzKeyVault.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ New-AzKeyVault [-Name] <String> [-ResourceGroupName] <String> [-Location] <Strin
[-EnabledForTemplateDeployment] [-EnabledForDiskEncryption] [-EnablePurgeProtection]
[-EnableRbacAuthorization] [-SoftDeleteRetentionInDays <Int32>] [-Sku <String>] [-Tag <Hashtable>]
[-NetworkRuleSet <PSKeyVaultNetworkRuleSet>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -301,6 +301,23 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SubscriptionId
The ID of the subscription.
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.
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.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Tag
Key-value pairs in the form of a hash table. For example:
@{key0="value0";key1=$null;key2="value2"}
Expand Down
Loading

0 comments on commit 07f48a6

Please sign in to comment.