Skip to content

Commit 4f878f7

Browse files
committed
updates1
1 parent 5b87897 commit 4f878f7

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

articles/azure-functions/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@
115115
- name: ARM template
116116
displayName: Resource Manager
117117
href: functions-create-first-function-resource-manager.md
118+
- name: Terraform
119+
displayName: Terraform, quickstart, get started
120+
href: functions-create-first-function-terraform.md
118121
- name: Azure Container Apps
119122
href: functions-deploy-container-apps.md
120123
displayName: container, Docker, ACA
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: 'Quickstart: Create and deploy Azure Functions resources from Terraform'
3+
description: In this quickstart, you create a resource group, storage account, blob storage account, and service plan in Azure for an Azure Functions Flex Consumption plan.
4+
ms.topic: quickstart
5+
ms.date: 03/26/2025
6+
ms.custom: devx-track-terraform
7+
ms.service: azure-functions
8+
author: ggailey777
9+
ms.author: glenga
10+
#customer intent: As a Terraform user, I want to learn how to create an Azure Functions Flex Consumption plan within a defined storage account and blob storage deployment container.
11+
content_well_notification:
12+
- AI-contribution
13+
---
14+
15+
# 'Quickstart: Create and deploy Azure Functions resources from Terraform'
16+
17+
In this quickstart, you use Terraform to create a function app in a Flex Consumption plan in Azure, along with its required Azure resources. Azure Functions Flex Consumption is a serverless compute service that helps you to run 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, a service plan, and the function app itself. The function app is configured to use blob storage and is set to run on a Linux operating system.
18+
19+
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
20+
21+
> [!div class="checklist"]
22+
> * Create an Azure resource group with a unique name.
23+
> * Generate a random string of 13 lowercase letters to name resources.
24+
> * Create a storage account in Azure.
25+
> * Create a blob storage container in the storage account.
26+
> * Create a service plan in Azure.
27+
> * Create a function app with a Flex Consumption plan in Azure.
28+
> * Output the names of the resource group, storage account, service plan, function app, and Azure Functions Flex Consumption plan.
29+
30+
## Prerequisites
31+
32+
- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
33+
34+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure).
35+
36+
## Implement the Terraform code
37+
38+
> [!NOTE]
39+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-functions). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-functions/TestRecord.md).
40+
>
41+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform).
42+
43+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
44+
45+
1. Create a file named `main.tf`, and insert the following code:
46+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-functions/main.tf":::
47+
48+
1. Create a file named `outputs.tf`, and insert the following code:
49+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-functions/outputs.tf":::
50+
51+
1. Create a file named `providers.tf`, and insert the following code:
52+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-functions/providers.tf":::
53+
54+
1. Create a file named `variables.tf`, and insert the following code:
55+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-functions/variables.tf":::
56+
57+
## Initialize Terraform
58+
59+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
60+
61+
## Create a Terraform execution plan
62+
63+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
64+
65+
## Apply a Terraform execution plan
66+
67+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
68+
69+
## Verify the results
70+
71+
### [Azure CLI](#tab/azure-cli)
72+
73+
1. Get the Azure resource group name.
74+
75+
```console
76+
resource_group_name=$(terraform output -raw resource_group_name)
77+
```
78+
79+
1. Get the storage account name.
80+
81+
```console
82+
sa_name=$(terraform output -raw sa_name)
83+
```
84+
85+
1. Get the service plan name.
86+
87+
```console
88+
asp_name=$(terraform output -raw asp_name)
89+
```
90+
91+
1. Get the function app plan name.
92+
93+
```console
94+
fa_name=$(terraform output -raw fa_name)
95+
```
96+
97+
1. Run `az functionapp show` to view the Azure Functions Flex Consumption plan.
98+
99+
```azurecli
100+
az functionapp show --name $function_app_name --resource-group $resource_group_name
101+
```
102+
103+
### [Azure PowerShell](#tab/azure-powershell)
104+
105+
1. Get the Azure resource group name.
106+
107+
```console
108+
$resource_group_name=$(terraform output -raw resource_group_name)
109+
```
110+
111+
1. Get the storage account name.
112+
113+
```console
114+
$sa_name=$(terraform output -raw sa_name)
115+
```
116+
117+
1. Get the service plan name.
118+
119+
```console
120+
$asp_name=$(terraform output -raw asp_name)
121+
```
122+
123+
1. Get the function app plan name.
124+
125+
```console
126+
$fa_name=$(terraform output -raw fa_name)
127+
```
128+
129+
1. Run `Get-AzFunctionApp` to view the Azure Functions Flex Consumption plan.
130+
131+
```azurepowershell
132+
Get-AzFunctionApp -Name $function_app_name -ResourceGroupName $resource_group_name
133+
```
134+
135+
---
136+
137+
## Clean up resources
138+
139+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
140+
141+
## Troubleshoot Terraform on Azure
142+
143+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot).
144+
145+
## Next steps
146+
147+
> [!div class="nextstepaction"]
148+
> [See more articles about Azure Functions Flex Consumption.](/search/?terms=Azure%20function%20app%20flex%20consumption%20and%20terraform)

0 commit comments

Comments
 (0)