Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change 'always-on' for an Azure Function App using Powershell?

I'm using a 'Basic' plan. I want to create a script which can switch 'always-on' to false, then change the service plan to the free tier. When I need the function again I can reverse the settings. Why am I doing this? So I can ensure the App service plan keeps the same outbound IP addresses. I don't want to be paying for a Basic plan all the time so a simple script to do this is required.

I am using the latest 'AZ' modules.

$site = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name  $SiteName
$site.SiteConfig.AlwaysOn = $false

Set-AzWebApp -ResourceGroupName $ResourceGroupName -Name $SiteName ???

Thanks

like image 820
Andrew Jocelyn Avatar asked Oct 23 '25 15:10

Andrew Jocelyn


1 Answers

Setting App Service Plan

Set-AzAppServicePlan -ResourceGroupName "myrgname"  -Name "my app service plan name" -Tier Basic -WorkerSize Small

For Free, you can change the Tier name to Free

Setting Always On

Connect-AzAccount

$webApp = Get-AzResource -ResourceType 'microsoft.web/sites' -ResourceGroupName 'myrgname' -ResourceName 'my function app name'

$webApp | Set-AzResource -PropertyObject @{"siteConfig" = @{"AlwaysOn" = $false}}

Here are two other similar SO posts.. difference is they don't tackle App Service Plan tier changes or make use of the latest Az modules Post1 and Post2

like image 113
Rohit Saigal Avatar answered Oct 25 '25 14:10

Rohit Saigal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!