, ,

Reduce Azure App Service Costs

Avatar de Vinicius

Today’s post will cover Reduce Azure App Service Costs and is part of the Azure Savings series of that cover ways to save money on Azure.

Once I heard, and used ever since this analogy, that using cloud resources is similar to use electricity: the more you use, the more expensive it will be. Although, you can also save money if you apply to the cloud what you currently do for electricity

Turn off things that are not in use!

Other posts from Azure Savings series
Azure Savings Scheduled Shutdown and Startup of Virtual Machines

Azure Delete unattached disks

Before we get started, please allow me to explain the difference between Azure App Service (Web App) and App Service Plans.

Azure App Service (Web App) vs App Service Plans

App Service and App Service Plans are not the same thing, and here is why

  • App Service Plan is the compute resources
  • App Service is the web server where the configuration and settings sit

So, we can establish the following relation between Web App and App Service Plan can be determined

azure app service vs app service plan blog vinicius deschamps

Where N App Services can use the same App Service Plan, as long as it still has resources to handle it

You can get a detailed explanation about Azure App Service (Web App) and App Service Plans here.

How App Service are billed?

You will be charged by the compute resources you are using, which means, the App Service Plan that determines how much that will cost for you.

Unlike Virtual Machines, App Service Plans are billed per second basis which means from the moment it becomes part of your environment, you are getting charged for it.

Another difference from Virtual Machines is that even if you Stop your App Service, charges still apply because the App Service Plan is running, and you cannot Deallocate it.

Before I explain about to you about saving some money with App Services, let me walk you through the different tiers you can have with App Service Plans.

App Service Plan tiers

Since the App Service Plan regulate how much you will pay, it has different flavors that determines the features you will get in your App Services.

  • Shared
    As you can imagine, the Shared tier runs an app on the same Azure VM as other App Service apps, including apps of other customers. You have two options to use a Shared tier
    • Free
    • Shared
  • Dedicated
    If you are looking to have apps in dedicated Azure VMs, this is the option you are looking for. You have the following options to use a Dedicated tier
    • Basic
    • Standard
    • Premium
    • Premium v2
    • Premium v3
  • Isolated
    Besides run on dedicated Azure VMs, Isolated tier also has their own Azure Virtual Networks

Reduce Azure App Service Costs

As you can imagine the App Service Plan tiers have different prices and, since there’s no way to simple Deallocate to stop charges, so how you can reduce Azure App Service Costs?

You have two options to make it happen: resize the App Service Plan to a lower tier or use the same App Service Plan for multiple App Services

IMPORTANT

Be careful to apply these changes to PRODUCTION environments, because modifying App Service Plans will affect the resources available for your application

Also, the idea behind saving money with these actions, would be a better fit if you have idle applications or test/dev environments that could use less compute resources to deliver the same work.

Resize App Service Plan

In App Services, select your App Service (1), navigate to Scale Up (App Service Plan) (2) and check which Tier your application currently is

azure app services settings scale up app service plan pricing tiers blog vinicius deschamps

Before you proceed by reducing the tier, you should check which Included Features your App Service Plan currently has

I am running P2v2, and these are the included features

  • Custom domains / SSL
  • Auto scale (up to 20 instances)
  • Staging slots
  • Daily backups
  • Traffic manager
azure app services settings scale up app service plan included features p2v2 blog vinicius deschamps

Let’s have a look at B1 and S1

B1 Included Features

B1 has Custom domains / SSL and Manual Scale but no support to Staging Slots, Daily Backups and Traffic Manager

azure app services settings scale up app service plan included features b1 blog vinicius deschamps

If you have one of the unsupported features in use, you either not able to resize to B1, for example if you are using Backup

azure updating app service plan backup exceed number of daily backups allowed for the hosting plan blog vinicius deschamps
The site(s) ‘blog-vinicius-deschamps’ have backup schedules that exceed the number of daily backups allowed for the hosting plan

Or you lose the ability to use the feature, for example Traffic Manager

App Service using P2v2 accessing through Traffic Manager address

azure updating app service plan traffic manager working blog vinicius deschamps

App Service resized to B1 accessing through Traffic Manager address

azure updating app service plan traffic manager not working blog vinicius deschamps

S1 Included Features

S1 has the same included features as P2v2, however, different limits for each feature, for example S1 allows 10 daily backups when P2v2 allows 50 daily backups

azure app services settings scale up app service plan included features s1 blog vinicius deschamps

If your App Service is below or at the limit of the included features at S1, then you shouldn’t have issues while resizing it, otherwise you might see errors while trying to perform that

For example, if you have more instances than the supported by S1

azure app services updating app service plan number of web workers exceeds the maximum allowed for the hosting plan blog vinicius deschamps
Number of Web workers exceeds the maximum allowed for the hosting plan

Or if you have more Staging slots than the supported by S1

azure updating app service plan staging slot exceed maximum number of slots allowed for the hosting plan blog vinicius deschamps
The site(s) ‘blog-vinicius-deschamps-01’ exceed maximum number of slots allowed for the hosting plan. Remove all deployment slots before scaling to a different mode.

Alright, I am running P2v2 and my application is using the following Included Features

  • Custom domains/SSL
  • 3 instances (Auto scale)
  • 1 Staging Slot
  • 1 daily backup

Having the features verified, and its limits, I can now safely resize my App Service Plan to S1 by choosing S1 (1) in the Scale Up (App Service plan), and hit Apply (2)

azure app service scale up app service plan s1 apply blog vinicius deschamps

Wait for the Update to be completed and receive The plan ‘app-service-plan-01’ was updated successfully!

azure updating app service plan the plan was updated successfully blog vinicius deschamps

Multiple App Services in a single App Service Plan

The main idea behind multiple App Services in a single App Service Plan is to use a single compute resource and reducing costs whenever it is possible.

IMPORTANT

You can move an app to another App Service plan, as long as the source plan and the target plan are in the same resource group and geographical region.

https://docs.microsoft.com/en-us/azure/app-service/app-service-plan-manage#move-an-app-to-another-app-service-plan

In App Services, select your App Service (1), navigate to Change App Service Plan (2) and hit Ok (3)

azure app service change app service plan blog vinicius deschamps

Wait for the Update to be completed and receive Changing App Service plan

azure changing app service plan blog vinicius deschamps

However, this will happen if the Destination App Service Plan has enough room at the Included Features, otherwise you will have some problems as previously shown

For example, I tried to change the App Service Plan from a P2v2 to a B1, but I have 5 instances (Scale Out), so I received the following message

azure changing app service plan failed to change to app service plan cannot complete the operation because the site will exceed the number of slots allowed for the basic sku blog vinicius deschamps

That said, you also should keep in mind to review the Included Features of the destination App Service Plan to avoid errors during the process.

And that’s it!

I hope you liked it, and I’ll see you on my next post!

Photo by Jp Valery on Unsplash

Avatar de Vinicius

Uma resposta para “Reduce Azure App Service Costs”

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *