Skip to content
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

Add Key Vault virtual machine extension examples and suggestions #15467

Merged
merged 7 commits into from
Jul 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Compute/Compute/help/Add-AzVMSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ For more information about the cmdlets, see [Azure Key Vault Cmdlets](/powershel

## EXAMPLES

### Example 1: Add a secret to a virtual machine
### Example 1: Add a secret to a virtual machine using the Azure Key Vault virtul machine extension
Copy link

@smotwani smotwani Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in virtual word.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will push and update.

To install certificates on a virtual machine it is recommended to use the [Azure Key Vault virtual machine extension for Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) or the [Azure Key Vault virtual machine extension for Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows).

```
mimckitt marked this conversation as resolved.
Show resolved Hide resolved
# Build settings
$settings = '{"secretsManagementSettings":
{ "pollingIntervalInS": "' + <pollingInterval> +
'", "certificateStoreName": "' + <certStoreName> +
'", "certificateStoreLocation": "' + <certStoreLoc> +
'", "observedCertificates": ["' + <observedCert1> + '","' + <observedCert2> + '"] } }'
mimckitt marked this conversation as resolved.
Show resolved Hide resolved
$extName = "KeyVaultForLinux"
$extPublisher = "Microsoft.Azure.KeyVault"
$extType = "KeyVaultForLinux"
# Start the deployment
Set-AzVmExtension -TypeHandlerVersion "2.0" -ResourceGroupName <ResourceGroupName> -Location <Location> -VMName <VMName> -Name $extName -Publisher $extPublisher -Type $extType -SettingString $settings
```

### Example 2: Add a secret to a virtual machine using Add-AzVMSecret
```
PS C:\> $VirtualMachine = New-AzVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id
PS C:\> $Credential = Get-Credential
Expand Down
22 changes: 21 additions & 1 deletion src/Compute/Compute/help/Add-AzVmssSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,27 @@ For more information about the cmdlets, see [Azure Key Vault Cmdlets](/powershel

## EXAMPLES

### Example 1: Add a secret to the VMSS
### Example 1: Add a secret to the VMSS using the Azure Key Vault virtual machine extension
To install certificates on a virtual machine it is recommended to use the [Azure Key Vault virtual machine extension for Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) or the [Azure Key Vault virtual machine extension for Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows).

```
# Build settings
$settings = '{"secretsManagementSettings":
{ "pollingIntervalInS": "' + <pollingInterval> +
'", "certificateStoreName": "' + <certStoreName> +
'", "certificateStoreLocation": "' + <certStoreLoc> +
'", "observedCertificates": ["' + <observedCert1> + '","' + <observedCert2> + '"] } }'
$extName = "KeyVaultForLinux"
$extPublisher = "Microsoft.Azure.KeyVault"
$extType = "KeyVaultForLinux"
# Add Extension to VMSS
$vmss = Get-AzVmss -ResourceGroupName <ResourceGroupName> -VMScaleSetName <VmssName>
Add-AzVmssExtension -VirtualMachineScaleSet $vmss -Name $extName -Publisher $extPublisher -Type $extType -TypeHandlerVersion "2.0" -Setting $settings
# Start the deployment
Update-AzVmss -ResourceGroupName <ResourceGroupName> -VMScaleSetName <VmssName> -VirtualMachineScaleSet $vmss
```

### Example 2: Add a secret to the VMSS using Add-AzVmssSecret
```
PS C:\> $Vault = Get-AzKeyVault -VaultName "ContosoVault"
PS C:\> $CertConfig = New-AzVmssVaultCertificateConfig -CertificateUrl "http://keyVaultName.vault.contoso.net/secrets/secretName/secretVersion" -CertificateStore "Certificates"
Expand Down