DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Create Azure Function App using Azure CLI command(az functionapp create)

By Ashok Nalam on 10 Sep 2020 | Category: Microsoft Azure | Tagged: azure azure functions azure cli 
We can create Azure function apps using code, Azure Portal or Azure CLI. In this post, we will see how to create an Azure function App using Azure CLI commands(az functionapp create).
  Discuss Add Comment   |  
Add rating Rate this resource   

Introduction

We can create Azure function apps using Code, Azure Portal or Azure CLI. In this post, we will see how to create an Azure function App using Azure CLI commands(az functionapp create). 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 centralindia region. 

rgname=rgdnmfncli 
region=centralindia
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 centralindia 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 4 digit numbers to storage account name(dnmsa).

Once the storage account is created, you will get a finished response.

Create a Function App

Below command creates a function app named (dnmhelloworldxxxx)in centralindia region under resource group(rgdnmfncli) with storage account mapping. Also we used Function Runtime 3.0 version.

functionappname=dnmhelloworld$RANDOM
az functionapp create --name $functionappname --storage-account $storageName --consumption-plan-location $region --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 “dnmhelloworld7233” app insights created for this function app with all Function App properties. 

Azure Function App created - using CLI commands

Fig: Azure Function App created - using CLI commands

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

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 8586  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.