How to automatically schedule the start and stopping of Azure Web App to save some cost?

EnterpriseArchitect 4,866 Reputation points
2024-05-05T15:06:52.89+00:00

After deploying the Web App and App Service plan as part of the https://github.com/OfficeDev/microsoft-teams-apps-company-communicator solution in Azure,

I'm wondering if there's an automated way to schedule when my Azure Web App starts and stops to save on costs.

Because the daily cost is so expensive even when the solution is not in use.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,988 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 78,506 Reputation points
    2024-05-05T18:41:37.6333333+00:00

    Hi,

    Stopping a Web App doesn't save any money since charges still accrue even when it is stopped. What you can do instead is to write a script to switch it to Free SKU and back to paid SKU on a schedule.

    In order to switch to Free SKU you must first disable features that are unavailable on Free. For example, remove bindings for custom domain(s). And naturally when switching back to paid SKU you need to add the binding(s) back.

    Please check your Web App and see which features you are using that are incompatible with Free and add comment below. You can start by attempting to switch it to Free and see if you get an error. Most common off the top of my head are custom domains, scaling, vNet integration.

    Thanks.

    -TP


2 additional answers

Sort by: Most helpful
  1. ajkuma 22,766 Reputation points Microsoft Employee
    2024-05-07T19:04:02.6566667+00:00

    Thanks for the additional follow-up on this.

    There is no direct to way accomplish this via portal. As TP and Marcin Policht mentioned - you may automate the scaling up/down operation using any of the below services.

    1. Logic App: Create a logic app workflow with HTTP action in it and thereby calling the App Service plans-update REST API.
      ( similar to the suggestions/in the URL shared by Marcin )
    2. Automation Account: Create a Script using either PowerShell Cmdlet Set-AzAppServicePlan or by using AzCLI Cmdlet az appservice plan update
    3. Azure Functions: Create a PowerShell Function App and run the above created script to scale up/down the App Service Plan (ASP).

    References:

    1 person found this answer helpful.

  2. Marcin Policht 13,020 Reputation points MVP
    2024-05-05T15:32:51.2466667+00:00

    Follow https://www.stevefenton.co.uk/blog/2020/07/start-and-stop-an-azure-app-service-on-a-schedule-with-azure-logic-apps/


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin