Skip to content

Instantly share code, notes, and snippets.

@ilmax
Created July 24, 2022 10:33
Show Gist options
  • Save ilmax/efaee63ccba80469ee51fd0a15565e73 to your computer and use it in GitHub Desktop.
Save ilmax/efaee63ccba80469ee51fd0a15565e73 to your computer and use it in GitHub Desktop.
Azure automation account runbook to scale up & down an App Service Plan
$errorActionPreference = "Stop"
Write-Output "--- Connecting to Azure using MSI..."
Connect-AzAccount -Identity
Write-Output "--- Reading variables...."
$rg = Get-AutomationVariable -Name 'rg-name'
$servicePlan = Get-AutomationVariable -Name 'service-plan-name'
$sk = Get-AutomationVariable -Name 'scale-down-sku'
Write-Output "--- Processing '$servicePlan' App Service Plan..."
$currentAppServicePlan = Get-AzAppServicePlan -ResourceGroupName $rg -Name $servicePlan
Write-Output "--- Converting '$servicePlan' to '$sk'..."
Set-AzAppServicePlan -ResourceGroupName $rg -Name $servicePlan -Tier $sk
Write-Output "--- Done!'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment