Skip to content

Files

Latest commit

c76d859 · May 12, 2022

History

History
131 lines (82 loc) · 4.57 KB

functions-create-first-function-bicep.md

File metadata and controls

131 lines (82 loc) · 4.57 KB
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

Quickstart: Create and deploy Azure Functions resources using Bicep

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]

Prerequisites

Azure account

Before you begin, you must have an Azure account with an active subscription. Create an account for free.

Review the Bicep file

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:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. 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.

Validate the deployment

Use Azure CLI or Azure PowerShell to validate the deployment.

az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG

Visit function app welcome page

  1. Use the output from the previous validation step to retrieve the unique name created for your function app.
  2. 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":::

Clean up resources

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

Next steps

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