How To Change Consumption To App Service Plan For An Azure Service

Introduction

 
This blog will help the techies who are looking to change the Azure app service plan of the existing app services. In this blog, we will see the business problem statement and how to solve the same with help of the PowerShell script. Let’s start.
 

Problem Statement

 
While working on the Azure service, we need to be always careful and conscious of the pricing. Hence in real time we may need to change the service plan of the app service to save/reduce the cost. In order to perform the same, if we want to change the plan of the app services from consumption to App service plan, in portal we don’t have option to make the same. The option to change service plan will be disabled in the portal with the warning text as “This feature is not available for apps on a consumption plan”. 
 
How To Change Consumption To App Service Plan For An Azure Service
 

Solution

 
This change can be performed by Azure PowerShell or Azure CLI. To perform the same below are the prerequisites.
  1. Windows PowerShell 5.0 or later.
  2. Nuget 2.8.5.201 or later.
  3. AzureRM module to be installed.
The below script will be helpful to change the plan.
  1. #AzureRM requires a minimum Windows PowerShell version of '5.0'  
  2. to run[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12  
  3. #AzureRM requires a minimum version of 2.8 .5 .201 NuGet  
  4. Install - PackageProvider - Name NuGet - MinimumVersion 2.8 .5 .201 - Force  
  5. Connect - AzureRmAccount  
  6. Select - AzureRmSubscription - SubscriptionId "<<Subscription ID>>"  
  7. #Resource Group name and region should be same  
  8. #Number of workers should be greater than zero to change the plan from Consumption to App service plan  
  9. Set - AzureRmWebApp - Name "<<App Name>>" - ResourceGroupName "<<Resource group name>>" - AppServicePlan "<<New App service plan>>"  
Happy Coding! Cheers!