Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 6.32 KB

functions-create-first-function-bicep.md

File metadata and controls

144 lines (109 loc) · 6.32 KB
titledescriptionauthorms.authorms.datems.topicms.servicezone_pivot_groupsms.custom
Create your function app resources in Azure using Bicep
Create and deploy to Azure a simple HTTP triggered serverless function using Bicep.
ggailey777
glenga
03/17/2025
quickstart
azure-functions
programming-languages-set-functions
subject-armqs, mode-arm, devx-track-bicep

Quickstart: Create and deploy Azure Functions resources using Bicep

In this article, you use Bicep to create a function app in a Flex Consumption plan in Azure, along with its required Azure resources. The function app provides a serverless execution context for your function code executions. The app uses Microsoft Entra ID with managed identities to connect to other Azure resources.

Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.

[!INCLUDE About Bicep]

After you create the function app, you can deploy your Azure Functions project code to that app. A final code deployment step is outside the scope of this quickstart article.

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 an Azure Quickstart Template.

:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.web/function-app-flex-managed-identities/main.bicep":::

This deployment file creates these Azure resources needed by a function app that securely connects to Azure services:

[!INCLUDE functions-azure-resources-list]

[!INCLUDE functions-deployment-considerations-infra]

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.

    ::: zone pivot="programming-language-csharp"

    az group create --name exampleRG --location <SUPPORTED_REGION> az deployment group create --resource-group exampleRG --template-file main.bicep --parameters functionAppRuntime=dotnet-isolated functionAppRuntimeVersion=8.0 

    ::: zone-end
    ::: zone pivot="programming-language-java"

    az group create --name exampleRG --location <SUPPORTED_REGION> az deployment group create --resource-group exampleRG --template-file main.bicep --parameters functionAppRuntime=java functionAppRuntimeVersion=17 

    ::: zone-end
    ::: zone pivot="programming-language-javascript,programming-language-typescript"

    az group create --name exampleRG --location <SUPPORTED_REGION> az deployment group create --resource-group exampleRG --template-file main.bicep --parameters functionAppRuntime=node functionAppRuntimeVersion=20 

    ::: zone-end
    ::: zone pivot="programming-language-python"

    az group create --name exampleRG --location <SUPPORTED_REGION> az deployment group create --resource-group exampleRG --template-file main.bicep --parameters functionAppRuntime=python functionAppRuntimeVersion=3.11 

    ::: zone-end ::: zone pivot="programming-language-powershell"

    az group create --name exampleRG --location <SUPPORTED_REGION> az deployment group create --resource-group exampleRG --template-file main.bicep --parameters functionAppRuntime=powerShell functionAppRuntimeVersion=7.4 

    ::: zone-end

    ::: zone pivot="programming-language-csharp"

    New-AzResourceGroup -Name exampleRG -Location <SUPPORTED_REGION> New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -functionAppRuntime "dotnet-isolated" -functionAppRuntimeVersion "8.0" 

    ::: zone-end
    ::: zone pivot="programming-language-java"

    New-AzResourceGroup -Name exampleRG -Location <SUPPORTED_REGION> New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -functionAppRuntime "java" -functionAppRuntimeVersion "17" 

    ::: zone-end
    ::: zone pivot="programming-language-javascript,programming-language-typescript"

    New-AzResourceGroup -Name exampleRG -Location <SUPPORTED_REGION> New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -functionAppRuntime "node" -functionAppRuntimeVersion "20" 

    ::: zone-end
    ::: zone pivot="programming-language-python"

    New-AzResourceGroup -Name exampleRG -Location <SUPPORTED_REGION> New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -functionAppRuntime "python" -functionAppRuntimeVersion "3.11" 

    ::: zone-end ::: zone pivot="programming-language-powershell"

    New-AzResourceGroup -Name exampleRG -Location <SUPPORTED_REGION> New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -functionAppRuntime "powershell" -functionAppRuntimeVersion "7.4" 

    ::: zone-end


    In this example, replace <SUPPORTED_REGION> with a region that supports the Flex Consumption plan.

    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 

[!INCLUDE functions-welcome-page]

Clean up resources

[!INCLUDE functions-cleanup-resources-infra]

Next steps

[!INCLUDE functions-quickstarts-infra-next-steps]

close