If you want to perform an maintenance in your VMSS which is behind an Application Gateway, then you can use the below script to update Application Gateway in such a way that traffic will be sent to othen VM/ a static page when you do the maintenance work on VMSS. 

 

This script does the following, 

  1. Removes the VMSS from the backend pool of Application Gateway.
  2. You then need to add manually a blob storage or another VMSS or VM to the backend pool of Application gateway
  3. Once the maintenance is done, you can re-add the VMSS to the existing backend pool.