How to Reboot Azure Application Gateway in Azure?

Steps for Rebooting an Application Gateway in Azure:

  1. Get Application Gateway Details 
  2. Stop Application Gateway
  3. Again Get App Gateway Details
  4. Start Application Gateway

Follow the steps for rebooting an application gateway in Azure using azure cloud shell or windows PowerShell.

Step 1: Switch to target azure subscription in which your azure app gateway exits using the following PowerShell commands.

Set-AzureContext -SubscriptionName "$<subscription_name_here>" | Out-Null

or Set-AzureRmContext -SubscriptionName "<subscription_name_here>" | Out-Null

Step 2: Get Azure application gateway resource details and store it to a variable.

$AppGw = Get-AzApplicationGateway -ResourceGroupName "<resourceGroup_name_here>" -Name "<appgw_name_here>"

Step 3: PowerShell command to Stop Azure Application Gateway

Stop-AzApplicationGateway -ApplicationGateway $AppGw

Step 4: Follow the same as step 2

$AppGw = Get-AzApplicationGateway -ResourceGroupName "$RgName" -Name "$AppGwName"

Step 5: PowerShell command to Start Azure Application Gateway

Start-AzApplicationGateway -ApplicationGateway $AppGw

PowerShell Automation Code to Reboot an Application Gateway in Azure:

Use the below PowerShell script to automate the process in single run.

$AppGwName = Read-Host "_appgw_name_here_>"
if (Get-AzApplicationGateway | where-object {$_.Name -eq $AppGwName}){
    $AppGw = Get-AzApplicationGateway | where-object {$_.Name -eq $AppGwName}
    Write-Host "Stopping the $AppGwName"
    Stop-AzApplicationGateway -ApplicationGateway $AppGw
    Write-Host "Starting the $AppGwName"
    Start-AzApplicationGateway -ApplicationGateway $AppGw
} 
else{
    Write-Host "Application Gateway Not Found!"
}