Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use Case
An 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 Service Principle Id for silent authentication
To perform START/STOP operation on Azure App Service, the job should have access to your subscription. Please run below Power-Shell script to create a native AD application from which we will get service principal ID that will be used to do silent authentication. This is a one time job.
Note : You need to be a Global admin on Active Directory to create the native AD application.
When you run this script, you will get prompt to provide Subscription Name, Password and then log in.
After completion, you will get information in output:
Note : Please keep a note of this information, we'll use it in following steps.
Create PowerShell to STOP/START App Service
If the application is running on multiple instances, then you can use below script to leverage Advanced 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
Note: Please follow the link below for information about scheduling web job using CRON expression:
Please sign in to use this experience.
Sign in