Azure App Services: Automate Application restart using Web Job

Use Case 

Application is hosted on Azure as App Service and you want to restart your application on a scheduled basis.

You can achieve this by creating a web job and placing a PowerShell script to STOP and START the web app. Please follow the steps below to implement this for your web app:


Get Azure profile for silent authentication 

To perform START/STOP operation of app service, the job should have access to your subscription. Please run below Power-Shell script to download and save your Azure profile.

NoteWhen you run the above PowerShell, you will get a prompt for login.


Create PowerShell to STOP/START App Service 

  • Create a new folder and place the publish profile downloaded in previous step.
  • Create a PowerShell and save as run.ps1


If the application is running on multiple instances, then you can use below script to leverage Advance Application restart. In this case below script will restart worker process on each instance one by one. This can help in minimizing the downtime.


Create a scheduled web job 

  • Create a zip file which contains both the files (ps1 and azureprofile.json).
  • Go to App Service -> Web Job and then create a triggered web job by uploading the zip file.


  • Make sure that Always on is enabled on the App Service where you are deploying this web job. Always on is required for triggered web jobs.


Note: Please follow the link below for information about scheduling web job using CRON expression:


Comments (1)

  1. Very helpful Article, thanks for sharing.

Skip to main content