Wednesday 6 January 2021

Create Windows or Linux Consumption Plan Using Azure CLI

While creating a function app with Azure CLI we can let it dynamically create a consumption plan, which would be created with a default name. However, if you want to have more control over naming of the consumption plan, it is better to create the consumption plan as a sperate step. Looking and Azure CLI documentation does not provide clear information on how to create a consumption plan. Therefore, let’s explore the needed commands to get a consumption plan on Windows or Linux platforms in this post.

If you try to create a Windows function app plan with below command which you can use to create a function app consumption plan with any other pricing tier it will fail saying sku is not supported. Consumption plan sku is Y1. However below command does not support creating consumption plans.

az functionapp plan create --name plan-myproj-consumption-test `

--resource-group rg-myproj-dev `

--sku Y1 `

--location eastus


Even if you try Linux consumption plan result is the same failure.

az functionapp plan create --name plan-myproj-consumption-test `

--resource-group rg-myproj-dev `

--sku Y1 `

--location eastus

--is-linux true


Let’s try t create the plan using create resources command and see how we can successfully create a Windows or Linux consumption plan.

Creating Windows Consumption Plan

With the below command to create a consumption plan for windows works fine.

az resource create `

--resource-group rg-consumptionplan-test `

--name plan-myproj-consumption-test `

--resource-type Microsoft.web/serverfarms `

--is-full-object `

--properties `

('{\"location\":\"eastus\",\"kind\":\"functionapp\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"}}')


Location and sku details should be specified as json for properties and double quotes are escaped with \ in above command. A consumption plan would be created successfully on windows platform as shown below.


Creating Linux Consumption Plan

With the below command a Linux consumption plan can be created. Secret is the usage of reserved as true in the properties. If you specify reserved property as false do not use the reserved property the default value false applies and the plan gets created as Windows consumption plan.

az resource create `

--resource-group rg-consumptionplan-test `

--name plan-myproj-consumption-test `

--resource-type Microsoft.web/serverfarms `

--is-full-object `

--properties ` ('{\"location\":\"eastus\",\"kind\":\"functionapp\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"},\"properties\":{\"reserved\":true}}')


A Linux consumption plan will be created as shown below. But note that you cannot have both Linux and Windows app service plan on same region in same resource group. (previous windows plan deleted before creating below Linux plan)

No comments:

Popular Posts