Skip to content

Commit 2823e4c

Browse files
Update use-azure-app-service-certificate-with-application-gateway.md
1 parent e0cdd78 commit 2823e4c

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

support/azure/app-service/connection-issues-with-ssl-or-tls/use-azure-app-service-certificate-with-application-gateway.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,41 @@ You can use App Service Certificate in Azure Application Gateway, but not direct
5858

5959
1. **Store App Service Certificate in Key Vault**: Navigate to the App Service Certificate resource. Then, use the **Key Vault** blade to store the certificate in a key vault of your choice.
6060

61-
2. **Enable Managed Identity for Application Gateway**: Enable user-assigned or system-assigned managed identity.
61+
2. **Enable Managed Identity for Application Gateway**: Enable user-assigned.
6262

6363
3. **Grant Access to key vault**: In the key vault, go to **Access Policies**, and add a policy for Application Gateway identity that has `get`, `list`,
6464
and `secret management` permissions.
6565

66-
4. **Reference Certificate from Key Vault**: Go to **Application Gateway** \> **Listeners** \> **+ Add Listener**, select **HTTPS**, and then select **Key Vault certificate**.
66+
4. Due to current limitations, it's necessary to assign user-assigned managed identity and SSL certificate to Application Gateway. This can be done using Azure PowerShell.
67+
68+
```PowerShell
69+
70+
# Connect to Azure and Authenticate
71+
Connect-AzAccount
72+
Select-AzSubscription -Subscription <customer subscription>
73+
Install-Module -Name Az.ManagedServiceIdentity
74+
# Define Variables
75+
$AppGwName = "<YourApplicationGatewayName>"
76+
$RGName = "<YourResourceGroupName>"
77+
$UserIdentityName = "<YourUserAssignedManagedIdentityName>"
78+
$vaultName = "<YourKeyVaultName>"
79+
$secretName = "<YourCertificateSecretName>"
80+
# Construct Key Vault Secret ID
81+
$secretId = "https://${vaultName}.vault.azure.net:443/secrets/${secretName}/"
82+
# Retrieve Application Gateway Object
83+
$AppGw = Get-AzApplicationGateway -Name $AppGwName -ResourceGroupName $RGName
84+
# Add SSL Certificate (Key Vault Reference)
85+
Add-AzApplicationGatewaySslCertificate -ApplicationGateway $AppGw -Name $secretName -KeyVaultSecretId $secretId
86+
# Retrieve User-Assigned Managed Identity
87+
$identity = Get-AzUserAssignedIdentity -Name $UserIdentityName -ResourceGroupName $rgname
88+
# Assign Managed Identity to Application Gateway
89+
Set-AzApplicationGatewayIdentity -ApplicationGateway $AppGw -UserAssignedIdentityId $identity.Id
90+
# Apply Changes to Azure
91+
Set-AzApplicationGateway -ApplicationGateway $AppGw
92+
93+
```
94+
95+
5. **Reference Certificate from Key Vault**: Go to **Application Gateway** \> **Listeners** \> **+ Add Listener**, select **HTTPS**, and then select **Certificate** which you added in the previous step.
6796
6897
> [!NOTE]
6998
> Currently, Key Vault integration supports only certificates that have the private key in `.pfx` format.

0 commit comments

Comments
 (0)