How do I pause an Azure App Service Plan?

Azure

Azure Problem Overview


I thought one of the advantages of Azure was that I could turn services on and off depending on when I want them to be available.

However I cant see how to pause my App Service Plan. Is it possible?

I want to use the S1 tier so that I can play with what it offers. However I want to be able to pause the cost accumulation when I am not using it.

I see from the app service pricing help that an app will still be billed for even though it is in the stopped state.

Yet the link also clearly states that I only pay for what I use. So how does that work?

Azure Solutions


Solution 1 - Azure

If you put your hosting plan onto the free tier, you will stop being charged for it. However if you have things like deployment slots and certificates these will be deleted.

The ability to turn services on and off, is more to do with being able to scale services, so if you need 50 servers for an hour you can easily do that.

What you can do to make your solution temporary is to create a deployment script, using Powershell or Resource manager Templates then you can deploy your solution for exactly as long as you need it and then delete it again when you don't. In this sense you can turn your services on and off at a whim.

Azure provides building blocks for you to create the solution you need, it is up to you to figure out how to best use those building blocks to create the solution you seek.

Edited to answer extended question.

If you want to use the S1 pricing plan, and not have it charge when you are not using it, the only way of achieving that is by using automation. Fortunately, this is reasonably trivial to achieve.

If you look at this template it is pretty much all configured to deploy a website from Github to Azure on demand. If you edit that to configure it to your needs you can have a new Azure website online with 2 minutes of running the script.

Then you would have another script that deleted it once you had finished.

Doing it this way you would loose no functionality, and probably learn quite a bit about what is possible with Azure along the way.

App Service Plan

An app service plan is the hardware that a web app runs on. In the free and shared tier your web apps share an instance with other web apps. In the other tiers you have a dedicated virtual machine. It is this virtual machine that you pay for. In that case it is irrelevant whether or not you have web apps running on your app service or not, you still have a virtual machine running and you will be charged for that.

To change the App Service Plan via PowerShell, you can run the following command

Set-AzureRmAppServicePlan -ResourceGroupName $rg -Name $AppServicePlan -Tier Free

Solution 2 - Azure

I was able to accomplish this using the dashboard by selecting the App Service Plan, clicking Scale up (App Service Plan), and then from there if you click Dev/Test you can select the Free tier.

Solution 3 - Azure

As others have mentioned, you need to script this. Fortunately, I created a repository with one-click deployment to your Azure resources.

https://github.com/jraps20/jrap-AzureVerticalScaling

The steps are intended to be as simple and generic as possible:

  1. Execute the one-click deployment from the repo readme
  2. Select the subscription, resource group etc.
  3. Deploy resource to Azure
  4. Set up your schedule to scale up and scale down as-needed

The scripting relies on runbooks and variables to maintain the previous state of each App Service Plan and App Services within those plans. Some App Services cannot be scaled due to specific settings being used (AlwaysOn, Use32BitWOrkerProcess, ClientCertEnabled, etc.). In those cases, the previous values are stored as variables prior to down scaling and then the original values are reapplied when the services are scaled up.

For more clarity, I have written a blog post that goes into detail. The post is pertaining to Sitecore, but applies to any App Service setup- Drastically Reduce Azure PaaS Hosting Costs in Non-Prod Environments With Scheduled Vertical Scaling. It also includes a brief video tutorial to show its use case.

Myself and others have been using this repository/approach for well over a year and it works great. I mostly use it for POC's to reduce costs when I'm not actively working on something. However, its main intention was for targeting non-prod environments to save costs during non-work hours.

Solution 4 - Azure

Azure App Service Plan is just an logical concept of a set of features and capacity that you can share across multiple apps. I don`t think you can "pause" a plan, instead you can pause your service. and depends on billing model of each service, you might or might not get charged.

Solution 5 - Azure

Pausing = Delete or lower tier. Scripting is the key.

  1. Design Diagram
  2. Use scripts to create (also consider shared resources)
  3. Delete using scripts
  4. Use scripts to recreate.

eg: If we use resource group properly per environment then Export-AzureRmResourceGroup will create a template for us (everything in the resource group will be pulled out as script). So we can delete it and recreate it anytime.

Solution 6 - Azure

To pause a VM and stop billing you need to shut is down and deallocate it. Just shutting down still has the capacity reserved as if its running.

Storage can't be shutdown - it can be moved to lower cost tiers.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKirstenView Question on Stackoverflow
Solution 1 - AzureMichael BView Answer on Stackoverflow
Solution 2 - AzureEricView Answer on Stackoverflow
Solution 3 - AzurejrapView Answer on Stackoverflow
Solution 4 - AzureXiaomin WuView Answer on Stackoverflow
Solution 5 - AzureBlue CloudsView Answer on Stackoverflow
Solution 6 - AzureKenView Answer on Stackoverflow