(Created page with "== Using Key Vault == Link for use on key vault with info on how to renew certificates: [https://learn.microsoft.com/en-gb/azure/application-gateway/key-vault-certs?WT.mc_id=Portal-Microsoft_Azure_HybridNetworking#key-vault-azure-role-based-access-control-permission-model TLS termination with Azure Key Vault certificates | Microsoft Learn]") |
No edit summary |
||
| Line 3: | Line 3: | ||
[https://learn.microsoft.com/en-gb/azure/application-gateway/key-vault-certs?WT.mc_id=Portal-Microsoft_Azure_HybridNetworking#key-vault-azure-role-based-access-control-permission-model TLS termination with Azure Key Vault certificates | Microsoft Learn] | [https://learn.microsoft.com/en-gb/azure/application-gateway/key-vault-certs?WT.mc_id=Portal-Microsoft_Azure_HybridNetworking#key-vault-azure-role-based-access-control-permission-model TLS termination with Azure Key Vault certificates | Microsoft Learn] | ||
Add certificate in azure key vault to application gateway available certificates when key vault is using RBAC:<syntaxhighlight lang="powershell"> | |||
# Get the Application Gateway we want to modify | |||
$appgw = Get-AzApplicationGateway -Name MyApplicationGateway -ResourceGroupName MyResourceGroup | |||
# Specify the resource id to the user assigned managed identity - This can be found by going to the properties of the managed identity | |||
Set-AzApplicationGatewayIdentity -ApplicationGateway $appgw -UserAssignedIdentityId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyManagedIdentity" | |||
# Get the secret ID from Key Vault | |||
$secret = Get-AzKeyVaultSecret -VaultName "MyKeyVault" -Name "CertificateName" | |||
$secretId = $secret.Id.Replace($secret.Version, "") # Remove the secret version so Application Gateway uses the latest version in future syncs | |||
# Specify the secret ID from Key Vault | |||
Add-AzApplicationGatewaySslCertificate -KeyVaultSecretId $secretId -ApplicationGateway $appgw -Name $secret.Name | |||
# Commit the changes to the Application Gateway | |||
Set-AzApplicationGateway -ApplicationGateway $appgw | |||
</syntaxhighlight> | |||
Latest revision as of 09:37, 8 August 2024
Using Key Vault
Link for use on key vault with info on how to renew certificates:
TLS termination with Azure Key Vault certificates | Microsoft Learn
Add certificate in azure key vault to application gateway available certificates when key vault is using RBAC:
# Get the Application Gateway we want to modify
$appgw = Get-AzApplicationGateway -Name MyApplicationGateway -ResourceGroupName MyResourceGroup
# Specify the resource id to the user assigned managed identity - This can be found by going to the properties of the managed identity
Set-AzApplicationGatewayIdentity -ApplicationGateway $appgw -UserAssignedIdentityId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyManagedIdentity"
# Get the secret ID from Key Vault
$secret = Get-AzKeyVaultSecret -VaultName "MyKeyVault" -Name "CertificateName"
$secretId = $secret.Id.Replace($secret.Version, "") # Remove the secret version so Application Gateway uses the latest version in future syncs
# Specify the secret ID from Key Vault
Add-AzApplicationGatewaySslCertificate -KeyVaultSecretId $secretId -ApplicationGateway $appgw -Name $secret.Name
# Commit the changes to the Application Gateway
Set-AzApplicationGateway -ApplicationGateway $appgw