Skip to content

Update KeyVault documentation #6308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 30, 2018
1 change: 1 addition & 0 deletions src/ResourceManager/KeyVault/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Update documentation with example output

## Version 5.0.0
* Breaking changes to support piping scenarios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Collections.Generic;
using System.Management.Automation;
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;

namespace Microsoft.Azure.Commands.KeyVault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Collections.Generic;
using System.Management.Automation;
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;

namespace Microsoft.Azure.Commands.KeyVault
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Globalization;
using System.Management.Automation;
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;
using Microsoft.Azure.Commands.KeyVault.Properties;

namespace Microsoft.Azure.Commands.KeyVault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Globalization;
using System.Management.Automation;
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;

namespace Microsoft.Azure.Commands.KeyVault
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

using System.Management.Automation;
using Microsoft.Azure.Commands.KeyVault.Models;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;
using Microsoft.Azure.KeyVault.Models;

namespace Microsoft.Azure.Commands.KeyVault
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using System.Management.Automation;
using Microsoft.Azure.Commands.KeyVault.Models;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;

namespace Microsoft.Azure.Commands.KeyVault
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Collections.Generic;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;
using Microsoft.Azure.KeyVault.Models;
using Microsoft.Azure.KeyVault.WebKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using System.Security.Cryptography.X509Certificates;
using System.Xml;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.KeyVault.Models;
using Microsoft.Azure.KeyVault.WebKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;


namespace Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts
namespace Microsoft.Azure.Commands.KeyVault.Models
{
public sealed class PSDeletedKeyVaultManagedStorageAccount : PSDeletedKeyVaultManagedStorageAccountIdentityItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;

namespace Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts
namespace Microsoft.Azure.Commands.KeyVault.Models
{
public class PSDeletedKeyVaultManagedStorageAccountIdentityItem : PSKeyVaultManagedStorageAccountIdentityItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using System;
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;

namespace Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts
namespace Microsoft.Azure.Commands.KeyVault.Models
{
public sealed class PSDeletedKeyVaultManagedStorageSasDefinition : PSDeletedKeyVaultManagedStorageSasDefinitionIdentityItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;

namespace Microsoft.Azure.Commands.KeyVault.Models.ManagedStorageAccounts
namespace Microsoft.Azure.Commands.KeyVault.Models
{
public class PSDeletedKeyVaultManagedStorageSasDefinitionIdentityItem : PSKeyVaultManagedStorageSasDefinitionIdentityItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal PSDeletedKeyVaultCertificate(DeletedCertificateBundle deletedCertificat

if (deletedCertificateBundle.Tags != null)
{
Tags = (Hashtable) deletedCertificateBundle.Tags;
Tags = deletedCertificateBundle.Tags.ConvertToHashtable();
}

ScheduledPurgeDate = deletedCertificateBundle.ScheduledPurgeDate;
Expand Down Expand Up @@ -123,7 +123,7 @@ internal PSDeletedKeyVaultCertificate(DeletedCertificateBundle deletedCertificat

if (deletedCertificateBundle.Tags != null)
{
Tags = (Hashtable) deletedCertificateBundle.Tags;
Tags = deletedCertificateBundle.Tags.ConvertToHashtable();
}

ScheduledPurgeDate = deletedCertificateBundle.ScheduledPurgeDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ The **Add-AzureKeyVaultCertificate** cmdlet starts the process of enrolling for
## EXAMPLES

### Example 1: Add a certificate
```
PS C:\>$Policy = New-AzureKeyVaultCertificatePolicy -SecretContentType "application/x-pkcs12" -SubjectName "CN=contoso.com" -IssuerName "Self" -ValidityInMonths 6 -ReuseKeyOnRenewal
```powershell
PS C:\> $Policy = New-AzureKeyVaultCertificatePolicy -SecretContentType "application/x-pkcs12" -SubjectName "CN=contoso.com" -IssuerName "Self" -ValidityInMonths 6 -ReuseKeyOnRenewal
PS C:\> Add-AzureKeyVaultCertificate -VaultName "ContosoKV01" -Name "TestCert01" -CertificatePolicy $Policy

Status : inProgress
Expand All @@ -38,7 +38,9 @@ CertificateSigningRequest : MIICpjCCAY4CAQAwFjEUMBIGA1UEAxMLY29udG9zby5jb20wggEi
YnC9Py7Wp7CHfKzuqeptUk2Tsu7B5dHB+o9Ypeeqw8fWhTN0GFGRKO7WjZQlDqL+lRNcjlFSaP022oIP0kmvVhBcmZqRQlALXccAaxEclFA/3y/aNj2gwWeKpH/pwAkZ39zMEzpQCaRfnQk7e3l4MV8cf
eC2HPYdRWkXxAeDcNPxBuVmKy49AzYvly+APNVDU3v66gxl3fIKrGRsKi2Cp/nO5rBxG2h8t+0Za4l/HJ7ZWR9wKbd/xg7JhdZZFVBxMHYzw8KQ0ys13x8HY+PXU92Y7yD3uC2Rcj+zbAf+Kg==
ErrorCode :
ErrorMessage : PS C:\>Get-AzureKeyVaultCertificateOperation -VaultName "ContosoKV01" -Name "TestCert01"
ErrorMessage :

PS C:\> Get-AzureKeyVaultCertificateOperation -VaultName "ContosoKV01" -Name "TestCert01"
Status : completed
CancellationRequested : False
CertificateSigningRequest : MIICpjCCAY4CAQAwFjEUMBIGA1UEAxMLY29udG9zby5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC73w3VRBOlgJ5Od1PjDh+2ytngNZp+ZP4fkuX8K1Ti5LA6Ih7eWx1fgAN/iTb6l
Expand All @@ -48,7 +50,10 @@ CertificateSigningRequest : MIICpjCCAY4CAQAwFjEUMBIGA1UEAxMLY29udG9zby5jb20wggEi
YnC9Py7Wp7CHfKzuqeptUk2Tsu7B5dHB+o9Ypeeqw8fWhTN0GFGRKO7WjZQlDqL+lRNcjlFSaP022oIP0kmvVhBcmZqRQlALXccAaxEclFA/3y/aNj2gwWeKpH/pwAkZ39zMEzpQCaRfnQk7e3l4MV8cf
eC2HPYdRWkXxAeDcNPxBuVmKy49AzYvly+APNVDU3v66gxl3fIKrGRsKi2Cp/nO5rBxG2h8t+0Za4l/HJ7ZWR9wKbd/xg7JhdZZFVBxMHYzw8KQ0ys13x8HY+PXU92Y7yD3uC2Rcj+zbAf+Kg==
ErrorCode :
ErrorMessage : PS C:\>Get-AzureKeyVaultCertificate -VaultName "ContosoKV01" -Name "TestCert01"
ErrorMessage :

PS C:\> Get-AzureKeyVaultCertificate -VaultName "ContosoKV01" -Name "TestCert01"

Name : testCert01
Certificate : [Subject]
CN=contoso.com
Expand All @@ -57,7 +62,7 @@ Certificate : [Subject]
CN=contoso.com

[Serial Number]
05979C5A2F0741D5A3B6F97673E8A118
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[Not Before]
2/8/2016 3:11:45 PM
Expand All @@ -66,9 +71,9 @@ Certificate : [Subject]
8/8/2016 4:21:45 PM

[Thumbprint]
3E9B6848AD1834284157D68B060F748037F663C8
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thumbprint : 3E9B6848AD1834284157D68B060F748037F663C8
Thumbprint : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Tags :
Enabled : True
Created : 2/8/2016 11:21:45 PM
Expand Down Expand Up @@ -198,8 +203,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## INPUTS

### None
This cmdlet does not accept any input.
### Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy

## OUTPUTS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ These events are determined by the certificate policy.
## EXAMPLES

### Example 1: Add a key vault certificate contact
```
PS C:\>Add-AzureKeyVaultCertificateContact -VaultName "ContosoKV01" -EmailAddress "[email protected]" -PassThru
```powershell
PS C:\> Add-AzureKeyVaultCertificateContact -VaultName "ContosoKV01" -EmailAddress "[email protected]" -PassThru

Email VaultName
----- ---------
[email protected] ContosoKV01
```

This command adds Patti Fuller as a certificate contact for the ContosoKV01 key vault and returns the **KeyVaultCertificateContact** object.
This command adds Patti Fuller as a certificate contact for the ContosoKV01 key vault and returns the list of contacts for the "ContosoKV01" vault.

## PARAMETERS

Expand Down Expand Up @@ -174,12 +178,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## INPUTS

### None
This cmdlet does not accept any input.
### Microsoft.Azure.Commands.KeyVault.Models.PSKeyVault

## OUTPUTS

### List<Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificateContact>
### Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificateContact

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,64 @@ backup of it that you can restore.
## EXAMPLES

### Example 1: Create a key
```
PS C:\>Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITSoftware' -Destination 'Software'
```powershell
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITSoftware' -Destination 'Software'

Vault Name : contoso
Name : ITSoftware
Version : 67da57e9cadf48a2ad8d366b115843ab
Id : https://contoso.vault.azure.net:443/keys/ITSoftware/67da57e9cadf48a2ad8d366b115843ab
Enabled : True
Expires :
Not Before :
Created : 5/21/2018 11:10:58 PM
Updated : 5/21/2018 11:10:58 PM
Purge Disabled : False
Tags :
```

This command creates a software-protected key named ITSoftware in the key vault named Contoso.

### Example 2: Create an HSM-protected key
```
PS C:\>Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITHsm' -Destination 'HSM'
```powershell
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITHsm' -Destination 'HSM'

Vault Name : contoso
Name : ITHsm
Version : 67da57e9cadf48a2ad8d366b115843ab
Id : https://contoso.vault.azure.net:443/keys/ITSoftware/67da57e9cadf48a2ad8d366b115843ab
Enabled : True
Expires :
Not Before :
Created : 5/21/2018 11:10:58 PM
Updated : 5/21/2018 11:10:58 PM
Purge Disabled : False
Tags :
```

This command creates an HSM-protected key in the key vault named Contoso.

### Example 3: Create a key with non-default values
```
PS C:\>$KeyOperations = 'decrypt', 'verify'
```powershell
PS C:\> $KeyOperations = 'decrypt', 'verify'
PS C:\> $Expires = (Get-Date).AddYears(2).ToUniversalTime()
PS C:\> $NotBefore = (Get-Date).ToUniversalTime()
PS C:\> $Tags = @{'Severity' = 'high'; 'Accounting' = null}
PS C:\> Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITHsmNonDefault' -Destination 'HSM' -Expires $Expires -NotBefore $NotBefore -KeyOps $KeyOperations -Disable -Tag $Tags
PS C:\> $Tags = @{'Severity' = 'high'; 'Accounting' = "true"}
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITHsmNonDefault' -Destination 'HSM' -Expires $Expires -NotBefore $NotBefore -KeyOps $KeyOperations -Disable -Tag $Tags

Vault Name : contoso
Name : ITHsmNonDefault
Version : 929bfc14db84439b823ffd1bedadaf5f
Id : https://contoso.vault.azure.net:443/keys/ITHsmNonDefault/929bfc14db84439b823ffd1bedadaf5f
Enabled : False
Expires : 5/21/2020 11:12:43 PM
Not Before : 5/21/2018 11:12:50 PM
Created : 5/21/2018 11:13:17 PM
Updated : 5/21/2018 11:13:17 PM
Purge Disabled : False
Tags : Name Value
Severity high
Accounting true
```

The first command stores the values decrypt and verify in the $KeyOperations variable.
Expand All @@ -127,8 +165,20 @@ severity and IT. The new key is disabled. You can enable it by using the **Set-A
cmdlet.

### Example 4: Import an HSM-protected key
```
PS C:\>Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITByok' -KeyFilePath 'C:\Contoso\ITByok.byok' -Destination 'HSM'
```powershell
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITByok' -KeyFilePath 'C:\Contoso\ITByok.byok' -Destination 'HSM'

Vault Name : contoso
Name : ITByok
Version : 67da57e9cadf48a2ad8d366b115843ab
Id : https://contoso.vault.azure.net:443/keys/ITByok/67da57e9cadf48a2ad8d366b115843ab
Enabled : True
Expires :
Not Before :
Created : 5/21/2018 11:10:58 PM
Updated : 5/21/2018 11:10:58 PM
Purge Disabled : False
Tags :
```

This command imports the key named ITByok from the location that the *KeyFilePath* parameter
Expand All @@ -139,9 +189,21 @@ For more information, see
[How to Generate and Transfer HSM-Protected Keys for Azure Key Vault](http://go.microsoft.com/fwlink/?LinkId=522252).

### Example 5: Import a software-protected key
```
PS C:\>$Password = ConvertTo-SecureString -String 'Password' -AsPlainText -Force
PS C:\> Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITPfx' -KeyFilePath 'C:\Contoso\ITPfx.pfx' -KeyFilePassword $Password
```powershell
PS C:\> $Password = ConvertTo-SecureString -String 'Password' -AsPlainText -Force
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITPfx' -KeyFilePath 'C:\Contoso\ITPfx.pfx' -KeyFilePassword $Password

Vault Name : contoso
Name : ITPfx
Version : 67da57e9cadf48a2ad8d366b115843ab
Id : https://contoso.vault.azure.net:443/keys/ITPfx/67da57e9cadf48a2ad8d366b115843ab
Enabled : True
Expires :
Not Before :
Created : 5/21/2018 11:10:58 PM
Updated : 5/21/2018 11:10:58 PM
Purge Disabled : False
Tags :
```

The first command converts a string into a secure string by using the **ConvertTo-SecureString**
Expand All @@ -152,11 +214,25 @@ The second command creates a software password in the Contoso key vault. The com
location for the key and the password stored in $Password.

### Example 6: Import a key and assign attributes
```
PS C:\>$Password = ConvertTo-SecureString -String 'password' -AsPlainText -Force
```powershell
PS C:\> $Password = ConvertTo-SecureString -String 'password' -AsPlainText -Force
PS C:\> $Expires = (Get-Date).AddYears(2).ToUniversalTime()
PS C:\> $Tags = @{ 'Severity' = 'high'; 'Accounting' = null }
PS C:\> Add-AzureKeyVaultKey -VaultName 'Contoso' -Name 'ITPfxToHSM' -Destination 'HSM' -KeyFilePath 'C:\Contoso\ITPfx.pfx' -KeyFilePassword $Password -Expires $Expires -Tag $Tags
PS C:\> $Tags = @{ 'Severity' = 'high'; 'Accounting' = "true" }
PS C:\> Add-AzureKeyVaultKey -VaultName 'contoso' -Name 'ITPfxToHSM' -Destination 'HSM' -KeyFilePath 'C:\Contoso\ITPfx.pfx' -KeyFilePassword $Password -Expires $Expires -Tag $Tags

Vault Name : contoso
Name : ITPfxToHSM
Version : 929bfc14db84439b823ffd1bedadaf5f
Id : https://contoso.vault.azure.net:443/keys/ITPfxToHSM/929bfc14db84439b823ffd1bedadaf5f
Enabled : True
Expires : 5/21/2020 11:12:43 PM
Not Before :
Created : 5/21/2018 11:13:17 PM
Updated : 5/21/2018 11:13:17 PM
Purge Disabled : False
Tags : Name Value
Severity high
Accounting true
```

The first command converts a string into a secure string by using the **ConvertTo-SecureString**
Expand Down Expand Up @@ -483,8 +559,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## INPUTS

### None
This cmdlet does not accept any input.
### Microsoft.Azure.Commands.KeyVault.Models.PSKeyVault

## OUTPUTS

Expand Down
Loading