Forum Discussion

itglobalservice's avatar
itglobalservice
Copper Contributor
Feb 22, 2023
Solved

Schedule script to scale up AppServicePlan

I need to scale up / down a Basic App Service Plan on a daily time.

 

Example:

8:00 am -> Scale UP B3

8:00 pm -> Scale DOWN B2

 

Using AZ CLI in PS all work fine with this simple script:

 

az login
az appservice plan update --name MyAppPlan --resource-group MyResourceGroup --sku B3 

 

But this require that I login manually to Azure 

Is it possibile to schedule script in windows task scheduler and integrating authentication ?

 

I also tried to use Azure Automated Powershell Runbooks with Managed Identity with this script:

 
try
{
    "Logging in to Azure..."
    Connect-AzAccount -Identity
}
catch {
    Write-Error -Message $_.Exception
    throw $_.Exception
}
 
Update-AzFunctionAppPlan -ResourceGroupName "MyResourceGroup" -Name "MyAppPlan" -Sku B3 -Force

 

But testing the script, I received this error:

"Failed - Only ElasticPremium sku is suported when updating a function app plan. Current plan sku is: Basic."

 

Could you help me to solve my issue ?

 

Thank you

  • itglobalservice 

     

    My suggestion would be to use Set-AzAppServicePlan in your Automation to do the resize, for example:


    Set-AzAppServicePlan -ResourceGroupName "MyResourceGroup" -Name "MyAppPlan" -workerSize Large

     

    -workerSize Large equates to B3, and -workerSize Medium is B2

     

     

    (edit- corrected a copy and paste error spotted by itglobalservice )

6 Replies

  • itglobalservice 

     

    My suggestion would be to use Set-AzAppServicePlan in your Automation to do the resize, for example:


    Set-AzAppServicePlan -ResourceGroupName "MyResourceGroup" -Name "MyAppPlan" -workerSize Large

     

    -workerSize Large equates to B3, and -workerSize Medium is B2

     

     

    (edit- corrected a copy and paste error spotted by itglobalservice )

    • itglobalservice's avatar
      itglobalservice
      Copper Contributor

      Thank you Chris.
      I will try this week your solution and let you know I noticed that you made a mistake in the example. You wrote "Set-AzFunctionAppPlan" and not "Set-AzAppServicePlan"

      • ChrisBradshaw's avatar
        ChrisBradshaw
        Iron Contributor
        Good spot- Thanks, I've corrected my reply in case anyone comes across this in the future.