Home > Net >  Start/stop a Azure Web App Azure Function/process
Start/stop a Azure Web App Azure Function/process

Time:10-26

I have deployed a web App in the Azure App Service, I would like to stop/start the web App using Time Triggered Azure Function or Azure Automation Service. My requirement is that we have the settings table in the DB which stores the data like on which day of the week and the between what times this application should be started/stopped. This database also resides in the same resource group as the where Azure App Services of the web app

enter image description here

I am to able not able to find any references for azure function/ azure processes that can start/stop the web apps dynamically looking upon the database. Also I am not sure which option should I be using. Most of the blogs talks about the stopping/starting the VMs. Any help is greatly appreciated.

CodePudding user response:

I don't know if this is what you are actually looking for, but to Start/Stop WebApp you can just hit the REST API:

Funcapp (Azure Function) TimeTrigger is quite easy to deploy, you just need to make cron like configuration in function.json file for your function (https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python). Time Trigger function, as per design, are triggered on specific dates, so if you want to align with the hours/days from your DB you funcapp cron need to be run then as well and e.g. compare if this is a time to start/stop web app. You can e.g. set funcapp cron to start every 30 mins and read DB data and act accordingly.

Or you can do it other way around, make your DB to trigger the function app when the date is met, this way you run function app only when needed, not every 30 mins. Here your function app would not be Time Trigger but e.g. HTTP trigger. Its all up to you.

  • Related