Create a Function App in an App Service plan

This Azure Functions sample script creates a function app, which is a container for your functions. The function app that is created uses a dedicated App Service plan, which means your server resources are always on.

If you don't have an Azure subscription, create a free account before you begin.


  • This tutorial requires version 2.0 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.

Sample script

This script creates an Azure Function app using a dedicated App Service plan.


# Function app and storage account names must be unique.

# Create a resource resourceGroupName
az group create \
  --name myResourceGroup \
  --location $region

# Create an azure storage account
az storage account create \
  --name $storageName \
  --location $region \
  --resource-group myResourceGroup \
  --sku Standard_LRS

# Create an App Service plan
az functionapp plan create \
  --name myappserviceplan \
  --resource-group myResourceGroup \
  --location $region \
  --sku B1

# Create a Function App
az functionapp create \
  --name $functionAppName \
  --storage-account $storageName \
  --plan myappserviceplan \
  --resource-group myResourceGroup \
  --functions-version 2

Clean up deployment

After the sample script has been run, the following command can be used to remove the resource group and all resources associated with it.

az group delete --name myResourceGroup

Script explanation

Each command in the table links to command specific documentation. This script uses the following commands:

Command Notes
az group create Creates a resource group in which all resources are stored.
az storage account create Creates an Azure Storage account.
az functionapp plan create Creates a Premium plan.
az functionapp create Creates a function app in the App Service plan.

Next steps

For more information on the Azure CLI, see Azure CLI documentation.

Additional Azure Functions CLI script samples can be found in the Azure Functions documentation.