title | description | author | ms.author | ms.date | ms.topic | ms.service | ms.custom |
---|---|---|---|---|---|---|---|
Create your function app resources in Azure using Bicep |
Create and deploy to Azure a simple HTTP triggered serverless function using Bicep. |
schaffererin |
v-eschaffer |
05/12/2022 |
quickstart |
azure-functions |
subject-armqs, devx-track-azurepowershell, mode-arm |
In this article, you use Bicep to create a function that responds to HTTP requests.
Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
[!INCLUDE About Bicep]
Before you begin, you must have an Azure account with an active subscription. Create an account for free.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.web/function-app-create-dynamic/main.bicep":::
The following four Azure resources are created by this Bicep file:
- Microsoft.Storage/storageAccounts: create an Azure Storage account, which is required by Functions.
- Microsoft.Web/serverfarms: create a serverless Consumption hosting plan for the function app.
- Microsoft.Web/sites: create a function app.
- microsoft.insights/components: create an Application Insights instance for monitoring.
-
Save the Bicep file as main.bicep to your local computer.
-
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters appInsightsLocation=<app-location>
New-AzResourceGroup -Name exampleRG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -appInsightsLocation "<app-location>"
[!NOTE] Replace <app-location> with the region for Application Insights, which is usually the same as the resource group.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use Azure CLI or Azure PowerShell to validate the deployment.
az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG
- Use the output from the previous validation step to retrieve the unique name created for your function app.
- Open a browser and enter the following URL: <https://<appName.azurewebsites.net>. Make sure to replace <\appName> with the unique name created for your function app.
When you visit the URL, you should see a page like this:
:::image type="content" source="../azure-functions/media/functions-create-first-function-bicep/function-app-bicep.png" alt-text="Function app welcome page" border="false":::
If you continue to the next step and add an Azure Storage queue output binding, keep all your resources in place as you'll build on what you've already done.
Otherwise, if you no longer need the resources, use Azure CLI, PowerShell, or Azure portal to delete the resource group and its resources.
az group delete --name exampleRG
Remove-AzResourceGroup -Name exampleRG
Now that you've publish your first function, learn more by adding an output binding to your function.
[!div class="nextstepaction"] Connect to an Azure Storage queue
[!div class="nextstepaction"] Connect to an Azure Storage queue
[!div class="nextstepaction"] Connect to an Azure Storage queue