Skip to content

Commit

Permalink
Add example for Az.KeyVault.Extension in secret related commands (#18636
Browse files Browse the repository at this point in the history
)
  • Loading branch information
BethanyZhou committed Jun 23, 2022
1 parent ade9cf5 commit 0d2e025
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,24 @@ Tags :

This command gets the current versions of all secrets in the key vault named Contoso that start with "secret".

### Example 9: Get a secret in azure key vault by command Get-Secret in module Microsoft.PowerShell.SecretManagement
```powershell
# Install module Microsoft.PowerShell.SecretManagement
Install-Module Microsoft.PowerShell.SecretManagement -Repository PSGallery -AllowPrerelease
# Register vault for Secret Management
Register-SecretVault -Name AzKeyVault -ModuleName Az.KeyVault -VaultParameters @{ AZKVaultName = 'test-kv'; SubscriptionId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }
# Set secret for vault AzKeyVault
$secure = ConvertTo-SecureString -String "Password" -AsPlainText -Force
Set-Secret -Vault AzKeyVault -Name secureSecret -SecureStringSecret $secure
Get-Secret -Vault AzKeyVault -Name secureSecret -AsPlainText
```

```output
Password
```

This example Gets a secret named `secureSecret` in azure key vault named `test-kv` by command `Get-Secret` in module `Microsoft.PowerShell.SecretManagement`.

## PARAMETERS

### -AsPlainText
Expand Down
19 changes: 19 additions & 0 deletions src/KeyVault/KeyVault/help/Remove-AzKeyVaultSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ Tags :
This command removes the secret named FinanceSecret from the key vault named Contoso.
The command specifies the *Force* and *Confirm* parameters, and, therefore, the cmdlet does not prompt you for confirmation.

### Example 3: Remove a secret in azure key vault by command Remove-Secret in module Microsoft.PowerShell.SecretManagement
```powershell
# Install module Microsoft.PowerShell.SecretManagement
Install-Module Microsoft.PowerShell.SecretManagement -Repository PSGallery -AllowPrerelease
# Register vault for Secret Management
Register-SecretVault -Name AzKeyVault -ModuleName Az.KeyVault -VaultParameters @{ AZKVaultName = 'test-kv'; SubscriptionId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }
# Set secret for vault AzKeyVault
$secure = ConvertTo-SecureString -String "Password" -AsPlainText -Force
Set-Secret -Vault AzKeyVault -Name secureSecret -SecureStringSecret $secure
Remove-Secret -Vault AzKeyVault -Name secureSecret
```

```output
None
```

This example removes a secret named `secureSecret` in azure key vault `test-kv` by command `Remove-Secret` in module `Microsoft.PowerShell.SecretManagement`.


### Example 3: Purge deleted secret from the key vault permanently
```powershell
Remove-AzKeyVaultSecret -VaultName 'Contoso' -Name 'FinanceSecret' -InRemovedState
Expand Down
17 changes: 17 additions & 0 deletions src/KeyVault/KeyVault/help/Set-AzKeyVaultSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ the attributes in variables.
The final command modifies values of the secret named ITSecret in the key vault named Contoso, by
using the values specified previously as variables.

### Example 3: Create a secret in azure key vault by command Set-Secret in module Microsoft.PowerShell.SecretManagement
```powershell
# Install module Microsoft.PowerShell.SecretManagement
Install-Module Microsoft.PowerShell.SecretManagement -Repository PSGallery -AllowPrerelease
# Register vault for Secret Management
Register-SecretVault -Name AzKeyVault -ModuleName Az.KeyVault -VaultParameters @{ AZKVaultName = 'test-kv'; SubscriptionId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }
# Set secret for vault AzKeyVault
$secure = ConvertTo-SecureString -String "Password" -AsPlainText -Force
Set-Secret -Name secureSecret -SecureStringSecret $secure -Vault AzKeyVault
```

```output
None
```

This example sets a secret named `secureSecret` in azure key vault `test-kv` by command `Set-Secret` in module `Microsoft.PowerShell.SecretManagement`.

## PARAMETERS

### -ContentType
Expand Down

0 comments on commit 0d2e025

Please sign in to comment.