Skip to content

Commit b33a6f9

Browse files
feat: move metadata config to submodule and add Windows .NET 10 example (#268)
* feat: move metadata config to submodule and add Windows .NET 10 example * linting
1 parent 590d29c commit b33a6f9

21 files changed

Lines changed: 519 additions & 2 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,12 @@ Source: ./modules/config_logs
24022402

24032403
Version:
24042404

2405+
### <a name="module_config_metadata"></a> [config\_metadata](#module\_config\_metadata)
2406+
2407+
Source: ./modules/config_metadata
2408+
2409+
Version:
2410+
24052411
### <a name="module_config_slotconfignames"></a> [config\_slotconfignames](#module\_config\_slotconfignames)
24062412

24072413
Source: ./modules/config_slotconfignames
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
<!-- Code generated by terraform-docs. DO NOT EDIT. -->
3+
# Windows Web App with .NET 10
4+
5+
This example deploys a Windows Web App configured with the .NET 10 application stack.
6+
7+
It provisions a Resource Group, App Service Plan, Log Analytics Workspace, Application Insights, and the Web App with `application_stack.dotnet` set to .NET 10.
8+
9+
The example uses `kind = "webapp"` and `os_type = "Windows"`.
10+
11+
```hcl
12+
resource "random_integer" "region_index" {
13+
max = length(local.azure_regions) - 1
14+
min = 0
15+
}
16+
17+
module "naming" {
18+
source = "Azure/naming/azurerm"
19+
version = "0.4.2"
20+
}
21+
22+
resource "azapi_resource" "resource_group" {
23+
location = local.azure_regions[random_integer.region_index.result]
24+
name = module.naming.resource_group.name_unique
25+
type = "Microsoft.Resources/resourceGroups@2025-04-01"
26+
body = {}
27+
tags = {
28+
SecurityControl = "Ignore" # Useful for test environments
29+
}
30+
}
31+
32+
resource "azapi_resource" "service_plan" {
33+
location = azapi_resource.resource_group.location
34+
name = module.naming.app_service_plan.name_unique
35+
parent_id = azapi_resource.resource_group.id
36+
type = "Microsoft.Web/serverfarms@2025-03-01"
37+
body = {
38+
kind = "app"
39+
sku = {
40+
name = "P1v2"
41+
}
42+
properties = {
43+
reserved = false
44+
zoneRedundant = true
45+
}
46+
}
47+
tags = {
48+
app = "${module.naming.app_service.name_unique}-win-dotnet10"
49+
}
50+
}
51+
52+
resource "azapi_resource" "log_analytics_workspace" {
53+
location = azapi_resource.resource_group.location
54+
name = "${module.naming.log_analytics_workspace.name}-win-dotnet10"
55+
parent_id = azapi_resource.resource_group.id
56+
type = "Microsoft.OperationalInsights/workspaces@2025-02-01"
57+
body = {
58+
properties = {
59+
retentionInDays = 30
60+
sku = {
61+
name = "PerGB2018"
62+
}
63+
}
64+
}
65+
}
66+
67+
resource "azapi_resource" "application_insights" {
68+
location = azapi_resource.resource_group.location
69+
name = "${module.naming.application_insights.name_unique}-win-dotnet10"
70+
parent_id = azapi_resource.resource_group.id
71+
type = "Microsoft.Insights/components@2020-02-02"
72+
body = {
73+
kind = "web"
74+
properties = {
75+
Application_Type = "web"
76+
WorkspaceResourceId = azapi_resource.log_analytics_workspace.id
77+
}
78+
}
79+
response_export_values = ["properties.ConnectionString", "properties.InstrumentationKey"]
80+
}
81+
82+
module "avm_res_web_site" {
83+
source = "../../"
84+
85+
location = azapi_resource.resource_group.location
86+
name = "${module.naming.app_service.name_unique}-win-dotnet10"
87+
parent_id = azapi_resource.resource_group.id
88+
service_plan_resource_id = azapi_resource.service_plan.id
89+
application_insights_connection_string = azapi_resource.application_insights.output.properties.ConnectionString
90+
application_insights_key = azapi_resource.application_insights.output.properties.InstrumentationKey
91+
enable_telemetry = var.enable_telemetry
92+
kind = "webapp"
93+
os_type = "Windows"
94+
public_network_access_enabled = true
95+
site_config = {
96+
application_stack = {
97+
dotnet = {
98+
dotnet_version = "v10.0"
99+
current_stack = "dotnet"
100+
}
101+
}
102+
}
103+
tags = {
104+
module = "Azure/avm-res-web-site/azurerm"
105+
version = "0.19.3"
106+
}
107+
}
108+
```
109+
110+
<!-- markdownlint-disable MD033 -->
111+
## Requirements
112+
113+
The following requirements are needed by this module:
114+
115+
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.9)
116+
117+
- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (~> 2.4)
118+
119+
- <a name="requirement_random"></a> [random](#requirement\_random) (>= 3.5.0, < 4.0.0)
120+
121+
## Resources
122+
123+
The following resources are used by this module:
124+
125+
- [azapi_resource.application_insights](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
126+
- [azapi_resource.log_analytics_workspace](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
127+
- [azapi_resource.resource_group](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
128+
- [azapi_resource.service_plan](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
129+
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)
130+
131+
<!-- markdownlint-disable MD013 -->
132+
## Required Inputs
133+
134+
No required inputs.
135+
136+
## Optional Inputs
137+
138+
The following input variables are optional (have default values):
139+
140+
### <a name="input_enable_telemetry"></a> [enable\_telemetry](#input\_enable\_telemetry)
141+
142+
Description: This variable controls whether or not telemetry is enabled for the module.
143+
For more information see <https://aka.ms/avm/telemetryinfo>.
144+
If it is set to false, then no telemetry will be collected.
145+
146+
Type: `bool`
147+
148+
Default: `true`
149+
150+
## Outputs
151+
152+
The following outputs are exported:
153+
154+
### <a name="output_location"></a> [location](#output\_location)
155+
156+
Description: This is the full output for the resource.
157+
158+
### <a name="output_name"></a> [name](#output\_name)
159+
160+
Description: This is the full output for the resource.
161+
162+
### <a name="output_resource_id"></a> [resource\_id](#output\_resource\_id)
163+
164+
Description: This is the full output for the resource.
165+
166+
### <a name="output_service_plan_id"></a> [service\_plan\_id](#output\_service\_plan\_id)
167+
168+
Description: The ID of the app service plan.
169+
170+
### <a name="output_service_plan_name"></a> [service\_plan\_name](#output\_service\_plan\_name)
171+
172+
Description: The name of the app service plan.
173+
174+
## Modules
175+
176+
The following Modules are called:
177+
178+
### <a name="module_avm_res_web_site"></a> [avm\_res\_web\_site](#module\_avm\_res\_web\_site)
179+
180+
Source: ../../
181+
182+
Version:
183+
184+
### <a name="module_naming"></a> [naming](#module\_naming)
185+
186+
Source: Azure/naming/azurerm
187+
188+
Version: 0.4.2
189+
190+
<!-- markdownlint-disable-next-line MD041 -->
191+
## Data Collection
192+
193+
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
194+
<!-- END_TF_DOCS -->
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- markdownlint-disable-next-line MD041 -->
2+
## Data Collection
3+
4+
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Windows Web App with .NET 10
2+
3+
This example deploys a Windows Web App configured with the .NET 10 application stack.
4+
5+
It provisions a Resource Group, App Service Plan, Log Analytics Workspace, Application Insights, and the Web App with `application_stack.dotnet` set to .NET 10.
6+
7+
The example uses `kind = "webapp"` and `os_type = "Windows"`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
locals {
2+
azure_regions = [
3+
"australiaeast"
4+
]
5+
}

examples/windows_dotnet10/main.tf

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
resource "random_integer" "region_index" {
2+
max = length(local.azure_regions) - 1
3+
min = 0
4+
}
5+
6+
module "naming" {
7+
source = "Azure/naming/azurerm"
8+
version = "0.4.2"
9+
}
10+
11+
resource "azapi_resource" "resource_group" {
12+
location = local.azure_regions[random_integer.region_index.result]
13+
name = module.naming.resource_group.name_unique
14+
type = "Microsoft.Resources/resourceGroups@2025-04-01"
15+
body = {}
16+
tags = {
17+
SecurityControl = "Ignore" # Useful for test environments
18+
}
19+
}
20+
21+
resource "azapi_resource" "service_plan" {
22+
location = azapi_resource.resource_group.location
23+
name = module.naming.app_service_plan.name_unique
24+
parent_id = azapi_resource.resource_group.id
25+
type = "Microsoft.Web/serverfarms@2025-03-01"
26+
body = {
27+
kind = "app"
28+
sku = {
29+
name = "P1v2"
30+
}
31+
properties = {
32+
reserved = false
33+
zoneRedundant = true
34+
}
35+
}
36+
tags = {
37+
app = "${module.naming.app_service.name_unique}-win-dotnet10"
38+
}
39+
}
40+
41+
resource "azapi_resource" "log_analytics_workspace" {
42+
location = azapi_resource.resource_group.location
43+
name = "${module.naming.log_analytics_workspace.name}-win-dotnet10"
44+
parent_id = azapi_resource.resource_group.id
45+
type = "Microsoft.OperationalInsights/workspaces@2025-02-01"
46+
body = {
47+
properties = {
48+
retentionInDays = 30
49+
sku = {
50+
name = "PerGB2018"
51+
}
52+
}
53+
}
54+
}
55+
56+
resource "azapi_resource" "application_insights" {
57+
location = azapi_resource.resource_group.location
58+
name = "${module.naming.application_insights.name_unique}-win-dotnet10"
59+
parent_id = azapi_resource.resource_group.id
60+
type = "Microsoft.Insights/components@2020-02-02"
61+
body = {
62+
kind = "web"
63+
properties = {
64+
Application_Type = "web"
65+
WorkspaceResourceId = azapi_resource.log_analytics_workspace.id
66+
}
67+
}
68+
response_export_values = ["properties.ConnectionString", "properties.InstrumentationKey"]
69+
}
70+
71+
module "avm_res_web_site" {
72+
source = "../../"
73+
74+
location = azapi_resource.resource_group.location
75+
name = "${module.naming.app_service.name_unique}-win-dotnet10"
76+
parent_id = azapi_resource.resource_group.id
77+
service_plan_resource_id = azapi_resource.service_plan.id
78+
application_insights_connection_string = azapi_resource.application_insights.output.properties.ConnectionString
79+
application_insights_key = azapi_resource.application_insights.output.properties.InstrumentationKey
80+
enable_telemetry = var.enable_telemetry
81+
kind = "webapp"
82+
os_type = "Windows"
83+
public_network_access_enabled = true
84+
site_config = {
85+
application_stack = {
86+
dotnet = {
87+
dotnet_version = "v10.0"
88+
current_stack = "dotnet"
89+
}
90+
}
91+
}
92+
tags = {
93+
module = "Azure/avm-res-web-site/azurerm"
94+
version = "0.19.3"
95+
}
96+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
output "location" {
2+
description = "This is the full output for the resource."
3+
value = module.avm_res_web_site.location
4+
}
5+
6+
output "name" {
7+
description = "This is the full output for the resource."
8+
value = module.avm_res_web_site.name
9+
}
10+
11+
output "resource_id" {
12+
description = "This is the full output for the resource."
13+
sensitive = true
14+
value = module.avm_res_web_site.resource_id
15+
}
16+
17+
output "service_plan_id" {
18+
description = "The ID of the app service plan."
19+
value = azapi_resource.service_plan.id
20+
}
21+
22+
output "service_plan_name" {
23+
description = "The name of the app service plan."
24+
value = azapi_resource.service_plan.name
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = "~> 1.9"
3+
4+
required_providers {
5+
azapi = {
6+
source = "Azure/azapi"
7+
version = "~> 2.4"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = ">= 3.5.0, < 4.0.0"
12+
}
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "enable_telemetry" {
2+
type = bool
3+
default = true
4+
description = <<DESCRIPTION
5+
This variable controls whether or not telemetry is enabled for the module.
6+
For more information see <https://aka.ms/avm/telemetryinfo>.
7+
If it is set to false, then no telemetry will be collected.
8+
DESCRIPTION
9+
}

locals.config.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,5 @@ locals {
114114
functionAppScaleLimit = local.is_function_app ? var.site_config.app_scale_limit : null
115115
localMySqlEnabled = local.is_web_app ? var.site_config.local_mysql_enabled : null
116116
autoSwapSlotName = var.site_config.auto_swap_slot_name
117-
metadata = module.site_config_helpers.site_config_metadata
118117
}
119118
}

0 commit comments

Comments
 (0)