Skip to content

Commit e32966e

Browse files
authored
Adding guidance for function app (microsoft#116)
* adding guidance for function app
1 parent 329bfd1 commit e32966e

File tree

6 files changed

+193
-0
lines changed

6 files changed

+193
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
formatter: "markdown table"
2+
3+
content: |-
4+
{{ .Resources }}
5+
{{ .Inputs }}
6+
{{ .Providers }}
7+
{{ .Requirements }}
8+
9+
output:
10+
file: readme.html.markdown
11+
mode: inject
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
THIS FILE IS GENERATED BY TFMOD-SCAFFOLD, PLEASE DO NOT MODIFY IT.
3+
IF YOU WANT TO USE A CUSTOMIZED CONFIGURATION, PLEASE CREATE YOUR OWN AND
4+
SET THIS FILE'S PATH TO $TFLINT_CONFIG ENVVIRONMENT VARIABLE.
5+
*/
6+
7+
plugin "azurerm" {
8+
enabled = true
9+
version = "0.18.0"
10+
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
11+
}
12+
13+
rule "terraform_comment_syntax" {
14+
enabled = true
15+
}
16+
17+
rule "terraform_deprecated_index" {
18+
enabled = true
19+
}
20+
21+
rule "terraform_deprecated_interpolation" {
22+
enabled = true
23+
}
24+
25+
rule "terraform_documented_outputs" {
26+
enabled = true
27+
}
28+
29+
rule "terraform_documented_variables" {
30+
enabled = true
31+
}
32+
33+
rule "terraform_module_pinned_source" {
34+
enabled = true
35+
}
36+
37+
rule "terraform_module_version" {
38+
enabled = true
39+
}
40+
41+
rule "terraform_naming_convention" {
42+
enabled = true
43+
}
44+
45+
rule "terraform_required_providers" {
46+
enabled = true
47+
}
48+
49+
rule "terraform_required_version" {
50+
enabled = true
51+
}
52+
53+
rule "terraform_standard_module_structure" {
54+
enabled = false
55+
}
56+
57+
rule "terraform_typed_variables" {
58+
enabled = true
59+
}
60+
61+
rule "terraform_unused_declarations" {
62+
enabled = true
63+
}
64+
65+
rule "terraform_unused_required_providers" {
66+
enabled = true
67+
}
68+
69+
rule "terraform_workspace_remote" {
70+
enabled = true
71+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
resource "azurerm_resource_group" "default" {
2+
name = "${var.name_prefix}-rg"
3+
location = var.location
4+
}
5+
6+
resource "azurerm_storage_account" "default" {
7+
name = "${var.name_prefix}sa"
8+
resource_group_name = azurerm_resource_group.default.name
9+
location = azurerm_resource_group.default.location
10+
account_tier = "Standard"
11+
account_replication_type = "LRS"
12+
13+
min_tls_version = "TLS1_2"
14+
}
15+
16+
resource "azurerm_service_plan" "default" {
17+
name = "${var.name_prefix}-sap"
18+
location = azurerm_resource_group.default.location
19+
resource_group_name = azurerm_resource_group.default.name
20+
sku_name = "Y1"
21+
os_type = "Linux"
22+
23+
}
24+
# please note:
25+
# You may see custom (~4) is set to the app's runtime version, along with a warning says “Your app is pinned to an unsupported runtime version for ‘dotnet’. For better performance, we recommend using one of our supported versions instead: xxx.”. This is because azure function v4 runtime requires .NET6.0 but the default value is 4.0. You need to set the .netframeworkversion to v6.0 to support azure funtion v4.
26+
# If you would like to set the function runtime version, please use functions_extension_version property, terraform will set the FUNCTIONS_EXTENSION_VERSION in app_setting block, you don't need to specify the key in app_setting block.
27+
# If you would like to set the required number of failed requests for an instance to be deemed unhealthy and removed from the load balancer under health check feature, using health_check_eviction_time_in_min property under site_config block. Terraform will set the key WEBSITE_HEALTHCHECK_MAXPINGFAILURES
28+
# in app_setting for you.
29+
30+
resource "azurerm_linux_function_app" "test" {
31+
name = "${var.name_prefix}-lfa"
32+
location = azurerm_resource_group.default.location
33+
resource_group_name = azurerm_resource_group.default.name
34+
service_plan_id = azurerm_service_plan.default.id
35+
storage_account_name = azurerm_storage_account.default.name
36+
storage_account_access_key = azurerm_storage_account.default.primary_access_key
37+
https_only = true
38+
builtin_logging_enabled = false
39+
functions_extension_version = "~4"
40+
41+
site_config {
42+
application_stack {
43+
dotnet_version = "6.0"
44+
}
45+
}
46+
}
47+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_version = ">=1.0"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = "~>3.8"
8+
}
9+
}
10+
}
11+
provider "azurerm" {
12+
features {}
13+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Azure Windows/ Linux Function App.
2+
3+
This template deploys an Azure Function App.
4+
<!-- Run the following commands on your Windows machine to update document -->
5+
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest terraform-docs markdown table --output-file readme.html.markdown --output-mode inject ./ -->
6+
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest markdown-table-formatter readme.html.markdown -->
7+
<!-- Run the following command to lint Terraform code with tflint -->
8+
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest tflint --config=.tflint.hcl -->
9+
<!-- Run the following command to lint Terraform code with Checkov -->
10+
<!-- docker run --rm -v ${pwd}:/src -w /src mcr.microsoft.com/azterraform:latest checkov --skip-framework dockerfile --quiet -d ./ -->
11+
<!-- -->
12+
<!-- BEGIN_TF_DOCS -->
13+
## Resources
14+
15+
| Name | Type |
16+
|---------------------------------------------------------------------------------------------------------------------------------------|----------|
17+
| [azurerm_linux_function_app.test](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app) | resource |
18+
| [azurerm_resource_group.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
19+
| [azurerm_service_plan.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) | resource |
20+
| [azurerm_storage_account.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) | resource |
21+
## Inputs
22+
23+
| Name | Description | Type | Default | Required |
24+
|-----------------------------------------------------------------------|---------------------------------------|----------|---------------|:--------:|
25+
| <a name="input_location"></a> [location](#input\_location) | Location to deploy the resource group | `string` | `"West US 2"` | no |
26+
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Prefix of the resource name | `string` | n/a | yes |
27+
## Providers
28+
29+
| Name | Version |
30+
|---------------------------------------------------------------|---------|
31+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | ~>3.8 |
32+
## Requirements
33+
34+
| Name | Version |
35+
|---------------------------------------------------------------------------|---------|
36+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.0 |
37+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~>3.8 |
38+
<!-- END_TF_DOCS -->
39+
## Example
40+
41+
To see how to run this example, see [Create an Azure Function App using Terraform](https://docs.microsoft.com/azure/developer/terraform/create-azure-function-app).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "name_prefix" {
2+
type = string
3+
description = "Prefix of the resource name"
4+
}
5+
6+
variable "location" {
7+
type = string
8+
description = "Location to deploy the resource group"
9+
default = "West US 2"
10+
}

0 commit comments

Comments
 (0)