App service Scale up and down Between Tier Automation

Muhammad Hammad Naeem 45 Reputation points
2023-08-01T11:46:43.3066667+00:00

I am trying to move my App service during off hours to Standard S1 and move to Premium V3 p1V3 during working hours. I was trying to use this script available in Git https://github.com/azureautomation/scale-an-azure-service-plan-up-or-down
But the run as account is not working for me. I tried to replace it with managed identity, but it has many errors.
it also has many unnecessary things I do not need.
Is there any way I can Scale my app service simply?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,073 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,507 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ben Gimblett 2,980 Reputation points Microsoft Employee
    2023-08-01T15:23:38.18+00:00

    Hey @Muhammad Hammad Naeem thanks for the question

    In the end runbooks are just PowerShell (or python etc, depending on which type) but there is a learning curve to using azure automation. The advantage is that once you're comfortable with Automation then the scripting is little different from just using PowerShell in a regular terminal window.

    Alternatives exist.

    Logic Apps
    Logic Apps is simpler in the sense you don't need to code, you can start a logic app based on a scheduled trigger and you could use the http trigger action to send an ARM REST API call to resize your web app. Logic Apps consumption would be the right place to do this. Managed service identity would need to be assigned to the logic app with permissions / RBAC to change the sku on your app service plan.

    Functions
    You could use Azure function in a similar way to automation, using a scheduled trigger and here too you could use script directly as functions support powershell. Again, you'd want a consumption function (to avoid cost) and a managed identity with the correct RBAC to the web app plan.

    However all 3 have a learning curve and anything you do against the control plane in Azure needs to be authorized, for running code that would be best via a Managed Identity with the correct RBAC permissions (in the same way , as an end user you need the right RBAC to change the plan tier via the portal UI).


  2. Muhammad Hammad Naeem 45 Reputation points
    2023-08-04T07:04:22.44+00:00

    I used Login app using Recurrence and and ARM (create or update resource).

    https://learn.microsoft.com/en-us/answers/questions/213088/logic-apps-azure-resource-manager-connector-how-to

    https://learn.microsoft.com/en-us/rest/api/appservice/app-service-plans/create-or-update?tabs=HTTP#examples

    In Recurrence I specify the time i want to trigger the logic app
    User's image

    And in ARM (create or update a resource), short Resource id will be your name of the appserviceplan.
    User's image