Renewing SSL Certificate for Azure Application Gateway (Application Gateway and WAF).

 **Note:** Please fill all script parameters. 

Scenario

You want to renew SSL Certificate without removing the listener.

note: Please keep the same certificate name (same certificate name that exist in the listener).

 

Requirements 

 

Script Content

The content of the script is reproduced below  

PowerShell
Edit|Remove
#Parameters 
$WAFName = "<WAFResourceName>" 
$ResourceGroup = "<ResourceGroupName>" 
$OldCert = "<OldCertficateName" 
$NewCertName = "<NewCertficateName>" 
$NewCertPath = "<FullCertficatePath (PFX only)>" 
$CertPass = Read-Host -AsSecureString -Prompt:"Insert PFX Password" 
 
#Main 
#Get WAF Resource (ApplicationGateway) 
$WAF = Get-AzureRmApplicationGateway -Name:$WAFName -ResourceGroupName:$ResourceGroup#Get Existing Certificates 
$Cert = Get-AzureRmApplicationGatewaySslCertificate -Name:$OldCert -ApplicationGateway:$WAF#Remove Certificate 
Remove-AzureRmApplicationGatewaySslCertificate -Name:$Cert.Name -ApplicationGateway:$WAF | Out-Null#Add New Certificate 
Add-AzureRmApplicationGatewaySslCertificate -Name:$NewCertName -CertificateFile:$NewCertPath -Password:$CertPass -ApplicationGateway:$WAF | Out-Null; 
 
#Set WAF Configuration 
Set-AzureRmApplicationGateway -ApplicationGateway:$WAF;