Create a function app for serverless code execution
This Azure Functions sample script creates a function app, which is a container for your functions. The function app is created using the consumption plan, which is ideal for event-driven serverless workloads.
Open Azure Cloud Shell
Azure Cloud Shell is a free, interactive shell that you can use to run the steps in this article. Common Azure tools are preinstalled and configured in Cloud Shell for you to use with your account. Select Copy to copy the code, paste it in Cloud Shell, and then press Enter to run it. There are a few ways to open Cloud Shell:
|Select Try It in the upper-right corner of a code block.|
|Open Cloud Shell in your browser.|
|Select the Cloud Shell button on the menu in the upper-right corner of the Azure portal.|
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run
az --version to find the version. If you need to install or upgrade, see Install the Azure CLI.
This script creates an Azure Function app using the consumption plan.
#!/bin/bash # Function app and storage account names must be unique. storageName=mystorageaccount$RANDOM functionAppName=myserverlessfunc$RANDOM # Create a resource group. az group create --name myResourceGroup --location westeurope # Create an Azure storage account in the resource group. az storage account create \ --name $storageName \ --location westeurope \ --resource-group myResourceGroup \ --sku Standard_LRS # Create a serverless function app in the resource group. az functionapp create \ --name $functionAppName \ --storage-account $storageName \ --consumption-plan-location westeurope \ --resource-group myResourceGroup
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
Each command in the table links to command specific documentation. This script uses the following commands:
|az group create||Creates a resource group in which all resources are stored.|
|az storage account create||Creates an Azure Storage account.|
|az functionapp create||Creates a function app.|
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.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.