Hello @Kalaimathy Murugesan ,
I understand that you have an application gateway with a backend pool that contains multiple VMSS and whenever you redeploy any VMSS, the application gateway needs to be restarted to reflect the changes or else it reports 502 error.
You also confirmed that during the redeployment of VMSS, an A record is created and there are updates to the DNS entries of the backend pool.
As mentioned in this doc, this is a by design behavior.
Issue: If there are updates to the DNS entries of the backend pool, then the backend health status cannot be retrieved by the Application gateway.
Cause: Application Gateway resolves the DNS entries for the backend pool at time of startup and doesn't update them dynamically while running.
Resolution: Application Gateway must be restarted after any modification to the backend server DNS entries to begin to use the new IP addresses. This operation can be completed via Azure PowerShell or Azure CLI.
Azure PowerShell
Get Azure Application Gateway
$appgw=Get-AzApplicationGateway -Name <appgw_name> -ResourceGroupName <rg_name>
Stop the Azure Application Gateway
Stop-AzApplicationGateway -ApplicationGateway $appgw
Start the Azure Application Gateway
Start-AzApplicationGateway -ApplicationGateway $appgw
Azure CLI
Stop the Azure Application Gateway
az network application-gateway stop -n <appgw_name> -g <rg_name>
Start the Azure Application Gateway
az network application-gateway start -n <appgw_name> -g <rg_name>
Kindly let us know if the above helps or you need further assistance on this issue.
----------------------------------------------------------------------------------------------------------------
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.