Skip to content

Commit 840c294

Browse files
committed
[Functions] Fixup of terraform quickstart
1 parent 7943ff4 commit 840c294

File tree

1 file changed

+50
-76
lines changed

1 file changed

+50
-76
lines changed

articles/azure-functions/functions-create-first-function-terraform.md

Lines changed: 50 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
title: 'Quickstart: Create and deploy Azure Functions resources from Terraform'
33
description: In this quickstart article, you create a function app in a Flex Consumption plan, along with the resource group, storage account, and blob storage container required by the app.
44
ms.topic: quickstart
5-
ms.date: 05/01/2025
5+
ms.date: 07/22/2025
66
ms.custom: devx-track-terraform
77
ms.service: azure-functions
8-
author: ggailey777
9-
ms.author: glenga
108
#customer intent: As a Terraform user, I want to learn how to create a function app in a Flex Consumption plan along with required storage account and blob storage container used for deployments.
119
content_well_notification:
1210
- AI-contribution
11+
zone_pivot_groups: programming-languages-set-functions
1312
---
1413

1514
# Quickstart: Create and deploy Azure Functions resources from Terraform
1615

17-
In this quickstart, you use Terraform to create a function app in a Flex Consumption plan in Azure Functions, along with other required Azure resources. The Flex Consumption plan provides serverless hosting that lets you run your code on demand without explicitly provisioning or managing infrastructure. It's used for processing data, integrating systems, internet-of-things computing, and building simple APIs and microservices. The resources created in this configuration include a unique resource group, a storage account, a blob storage container, the Flex Consumption plan, and the function app itself. The function app runs on Linux and is configured to use blob storage for code deployments.
16+
In this quickstart, you use Terraform to create a function app in a Flex Consumption plan in Azure Functions, along with other required Azure resources. The Flex Consumption plan provides serverless hosting that lets you run your code on demand without explicitly provisioning or managing infrastructure. The function app runs on Linux and is configured to use Azure Blob storage for code deployments.
1817

1918
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
2019

@@ -50,94 +49,69 @@ The sample code for this article is located in the [Azure Terraform GitHub repo]
5049
1. Create a file named `variables.tf`, and insert the following code:
5150
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-functions/variables.tf":::
5251

53-
> [!IMPORTANT]
54-
> If you are using the 4.x azurerm provider, you must [explicitly specify the Azure subscription ID](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide#specifying-subscription-id-is-now-mandatory) to authenticate to Azure before running the Terraform commands.
55-
>
56-
> One way to specify the Azure subscription ID without putting it in the `providers` block is to specify the subscription ID in an environment variable named `ARM_SUBSCRIPTION_ID`.
57-
>
58-
> For more information, see the [Azure provider reference documentation](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#argument-reference).
52+
1. Use this Azure CLI command to set the `ARM_SUBSCRIPTION_ID` environment variable to the ID of your current subscription:
53+
54+
```azurecli
55+
export ARM_SUBSCRIPTION_ID=$(az account show --query "id" --output tsv)
56+
```
57+
58+
You must have this variable set for Terraform to be able to authenticate to your Azure subscription.
5959
6060
## Initialize Terraform
6161
6262
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
6363
6464
## Create a Terraform execution plan
6565
66-
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
66+
Run [terraform plan](https://www.terraform.io/docs/commands/plan.html) to create an execution plan.
67+
68+
::: zone pivot="programming-language-csharp"
69+
```console
70+
terraform plan -out main.tfplan -var="runtime_name=dotnet-isolated" -var="runtime_version=8"
71+
```
72+
::: zone-end
73+
::: zone pivot="programming-language-powershell"
74+
```console
75+
terraform plan -out main.tfplan -var="runtime_name=powershell" -var="runtime_version=7.4"
76+
```
77+
::: zone-end
78+
::: zone pivot="programming-language-python"
79+
```console
80+
terraform plan -out main.tfplan -var="runtime_name=python" -var="runtime_version=3.12"
81+
```
82+
::: zone-end
83+
::: zone pivot="programming-language-java"
84+
```console
85+
terraform plan -out main.tfplan -var="runtime_name=java" -var="runtime_version=21"
86+
```
87+
::: zone-end
88+
::: zone pivot="programming-language-javascript,programming-language-typescript"
89+
```console
90+
terraform plan -out main.tfplan -var="runtime_name=node" -var="runtime_version=20"
91+
```
92+
::: zone-end
93+
94+
Make sure that `runtime_version` matches the language stack version you verified locally. Select your preferred language stack at the [top](#top) of the article.
95+
96+
[!INCLUDE [terraform-plan-notes.md](terraform-plan-notes.md)]
6797

6898
## Apply a Terraform execution plan
6999

70100
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
71101

72102
## Verify the results
73103

74-
### [Azure CLI](#tab/azure-cli)
75-
76-
1. Get the Azure resource group name.
77-
78-
```console
79-
resource_group_name=$(terraform output -raw resource_group_name)
80-
```
81-
82-
1. Get the storage account name.
83-
84-
```console
85-
sa_name=$(terraform output -raw sa_name)
86-
```
104+
The `outputs.tf` file returns these values for your new function app:
87105

88-
1. Get the service plan name.
89-
90-
```console
91-
asp_name=$(terraform output -raw asp_name)
92-
```
93-
94-
1. Get the function app plan name.
95-
96-
```console
97-
fa_name=$(terraform output -raw fa_name)
98-
```
99-
100-
1. Run `az functionapp show` to view the Azure Functions Flex Consumption plan.
101-
102-
```azurecli
103-
az functionapp show --name $function_app_name --resource-group $resource_group_name
104-
```
105-
106-
### [Azure PowerShell](#tab/azure-powershell)
107-
108-
1. Get the Azure resource group name.
109-
110-
```console
111-
$resource_group_name=$(terraform output -raw resource_group_name)
112-
```
113-
114-
1. Get the storage account name.
115-
116-
```console
117-
$sa_name=$(terraform output -raw sa_name)
118-
```
119-
120-
1. Get the service plan name.
121-
122-
```console
123-
$asp_name=$(terraform output -raw asp_name)
124-
```
125-
126-
1. Get the function app plan name.
127-
128-
```console
129-
$fa_name=$(terraform output -raw fa_name)
130-
```
131-
132-
1. Run `Get-AzFunctionApp` to view the Azure Functions Flex Consumption plan.
133-
134-
```azurepowershell
135-
Get-AzFunctionApp -Name $function_app_name -ResourceGroupName $resource_group_name
136-
```
137-
138-
---
106+
| Value | Description |
107+
| --- | --- |
108+
| `resource_group_name` | The name of the resource group you created. |
109+
| `sa_name` | The name of the Azure storage account required by the Functions host. |
110+
| `asp_name` | The name of the Flex Consumption plan that hosts your new app. |
111+
| `fa_name` | The name of your new function app. |
112+
| `fa_url` | The URL of your new function app endpoint. |
139113

140-
Open a browser and enter the following URL: **https://<fa_name>.azurewebsites.net**. Replace the placeholder `<fa_name>` with the value output by Terraform.
114+
Open a browser and browse to the URL location in `fa_url`.
141115

142116
:::image type="content" source="media/functions-create-first-function-terraform/function-app-terraform.png" alt-text="Screenshot of Azure Functions app 'Welcome page'." border="false":::
143117

0 commit comments

Comments
 (0)