Introduction
In this post, we will see how to create an Azure function App in Premium Plan using Azure CLI commands. The Azure CLI can be launched from Azure Portal(cloud shell icon on top) or using https://shell.azure.com/ or you can install Azure CLI locally.
Create Resource Group
Below command creates a resource group(rgdnmfncli) in eastasia region.
rgname=rgdnmfncli
region=eastasia
az group create --name $rgname --location $region
In the CLI command, $rgname and $region are variables which are re-used in other commands. Once the resource group is created, you will get a Succeeded message.
Create Azure Storage Account
Storage account is mandatory to create a Function App. Below command creates storage account named (dnmsaxxxx)in eastasia region under resource group(rgdnmfncli).
storageName=dnmsa$RANDOM
az storage account create --name $storageName --location $region --resource-group $rgname --sku Standard_LRS
In the CLI command, $storageName is the variable which can be re-used in other commands. Azure function and storage account names has to be unique so we have added $RANDOM. $RANDOM is an internal bash function which generates and appends random numbers to storage account name(dnmsa).
Once the storage account is created, you will get a finished response.
Create a Function App Premium Plan
Below command creates a function app premium plan named (functionapppremiumplan)in eastasia region under resource group(rgdnmfncli) with EP1 plan. EP stands for Elastic Premium and other sku values are EP2 and EP3.
functionappplanname=functionapppremiumplan
az functionapp plan create --name $functionappplanname --location $region --resource-group $rgname --sku EP1
Note: First I selected, non supported region(centralindia) for Premium plan in the command but I got error as “
The pricing tier 'ElasticPremium' is not allowed in this resource group”. To get supported regions for Premium plan, refer
https://azure.microsoft.com/en-us/global-infrastructure/services/?products=functions Create a Function App
Below command creates a function app named (dnmhelloworldxxxx)in eastasia region under resource group(rgdnmfncli) with storage account mapping under Elastic plan. Also we used Function Runtime 3.0 version.
functionappname=dnmhelloworld$RANDOM
az functionapp create --name $functionappname --storage-account $storageName --plan $functionappplanname --resource-group $rgname --functions-version 3
Once the Function App is created, you will get a finished response. Also, you will get a message like “dnmhelloworld8310” app insights created for this function app with all Function App properties.
Fig 1 : Azure Function App resources created - using CLI commands
Fig 2 : Azure Function App created in Elastic premium plan
Delete Resource Group
Below command deletes the created resource group(rgdnmfncli) to clean up all your resources under the resource group.
rgname=rgdnmfncli
az group delete --name $rgname
It asks “Are you sure you want to perform this operation? (y/n) - type y and press enter and after some time it deletes all your resources including the resource group.
References