Skip to content

Commit d1a82ac

Browse files
committed
adding vnet integration examples and documentation
1 parent ec6bfed commit d1a82ac

File tree

5 files changed

+583
-0
lines changed

5 files changed

+583
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ VNet integration gives your app access to resources in your VNet, but it doesn't
313313

314314
This feature can be enabled by setting up `enable_vnet_integration` varaible to `true` and providing a valid `subnet_id`. The subnet must have a `service_delegation` configured for `Microsoft.Web/serverFarms`
315315

316+
[Example usage of App service with VNet Integration](examples/app-service-with-vnet-integration/)
317+
316318
## App Insights
317319

318320
Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. Use it to monitor your live applications. It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js, Java, and Python hosted on-premises, hybrid, or any public cloud. It integrates with your DevOps process, and has connection points to a variety of development tools. It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center.

examples/README.md

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Azure App Service (Web Apps) Terraform Module
2+
3+
Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points.
4+
5+
## Module Usage to create simple app service with optional resoruces
6+
7+
```hcl
8+
# Azurerm Provider configuration
9+
provider "azurerm" {
10+
features {}
11+
}
12+
13+
module "app-service" {
14+
source = "kumarvna/app-service/azurerm"
15+
version = "1.0.0"
16+
17+
# By default, this module will not create a resource group. Location will be same as existing RG.
18+
# proivde a name to use an existing resource group, specify the existing resource group name,
19+
# set the argument to `create_resource_group = true` to create new resrouce group.
20+
resource_group_name = "rg-shared-westeurope-01"
21+
22+
# App service plan setttings and supported arguments. Default name used by module
23+
# To specify custom name use `app_service_plan_name` with a valid name.
24+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
25+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
26+
service_plan = {
27+
kind = "Windows"
28+
size = "P1v2"
29+
tier = "PremiumV2"
30+
}
31+
32+
# App Service settings and supported arguments
33+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
34+
app_service_name = "myapp-poc-project"
35+
enable_client_affinity = true
36+
37+
# A `site_config` block to setup the application environment.
38+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
39+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
40+
site_config = {
41+
always_on = true
42+
dotnet_framework_version = "v2.0"
43+
ftps_state = "FtpsOnly"
44+
managed_pipeline_mode = "Integrated"
45+
use_32_bit_worker_process = true
46+
windows_fx_version = "DOTNETCORE|2.1"
47+
}
48+
49+
# (Optional) A key-value pair of Application Settings
50+
app_settings = {
51+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
52+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
53+
DiagnosticServices_EXTENSION_VERSION = "~3"
54+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
55+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
56+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
57+
XDT_MicrosoftApplicationInsights_Java = "1"
58+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
59+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
60+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
61+
}
62+
63+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
64+
# You can configure the backups to be retained up to an indefinite amount of time.
65+
# Azure storage account and container in the same subscription as the app that you want to back up.
66+
# This module creates a Storage Container to keep the all backup items.
67+
# Backup items - App configuration , File content, Database connected to your app
68+
enable_backup = true
69+
storage_account_name = "stdiagfortesting1"
70+
backup_settings = {
71+
enabled = true
72+
name = "DefaultBackup"
73+
frequency_interval = 1
74+
frequency_unit = "Day"
75+
retention_period_in_days = 90
76+
}
77+
78+
# By default App Insight resource is created by this module.
79+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
80+
# Specifies the type of Application by setting up `application_insights_type` with valid string
81+
# Specifies the retention period in days using `retention_in_days`. Default 90.
82+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
83+
app_insights_name = "otkpocshared"
84+
85+
# Adding TAG's to your Azure resources
86+
tags = {
87+
ProjectName = "demo-internal"
88+
Env = "dev"
89+
Owner = "user@example.com"
90+
BusinessUnit = "CORP"
91+
ServiceClass = "Gold"
92+
}
93+
}
94+
```
95+
96+
## Module Usage to create app service and optional resoruces with VNet integration
97+
98+
```hcl
99+
# Azurerm Provider configuration
100+
provider "azurerm" {
101+
features {}
102+
}
103+
104+
module "vnet" {
105+
source = "kumarvna/vnet/azurerm"
106+
version = "2.1.0"
107+
108+
create_resource_group = false
109+
resource_group_name = "rg-shared-westeurope-01"
110+
vnetwork_name = "vnet-shared-hub-westeurope-002"
111+
location = "westeurope"
112+
vnet_address_space = ["10.2.0.0/16"]
113+
create_network_watcher = false
114+
115+
subnets = {
116+
web_subnet = {
117+
subnet_name = "snet-webapp"
118+
subnet_address_prefix = ["10.2.1.0/24"]
119+
delegation = {
120+
name = "testdelegation"
121+
service_delegation = {
122+
name = "Microsoft.Web/serverFarms"
123+
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
124+
}
125+
}
126+
}
127+
}
128+
129+
# Adding TAG's to your Azure resources (Required)
130+
tags = {
131+
ProjectName = "demo-internal"
132+
Env = "dev"
133+
Owner = "user@example.com"
134+
BusinessUnit = "CORP"
135+
ServiceClass = "Gold"
136+
}
137+
}
138+
139+
module "app-service" {
140+
source = "kumarvna/app-service/azurerm"
141+
version = "1.0.0"
142+
143+
# By default, this module will not create a resource group. Location will be same as existing RG.
144+
# proivde a name to use an existing resource group, specify the existing resource group name,
145+
# set the argument to `create_resource_group = true` to create new resrouce group.
146+
resource_group_name = "rg-shared-westeurope-01"
147+
148+
# App service plan setttings and supported arguments. Default name used by module
149+
# To specify custom name use `app_service_plan_name` with a valid name.
150+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
151+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
152+
service_plan = {
153+
kind = "Windows"
154+
size = "P1v2"
155+
tier = "PremiumV2"
156+
}
157+
158+
# App Service settings and supported arguments
159+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
160+
app_service_name = "kumarsmypocproject"
161+
enable_client_affinity = true
162+
163+
# A `site_config` block to setup the application environment.
164+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
165+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
166+
site_config = {
167+
always_on = true
168+
dotnet_framework_version = "v2.0"
169+
ftps_state = "FtpsOnly"
170+
managed_pipeline_mode = "Integrated"
171+
use_32_bit_worker_process = true
172+
windows_fx_version = "DOTNETCORE|2.1"
173+
}
174+
175+
# (Optional) A key-value pair of Application Settings
176+
app_settings = {
177+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
178+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
179+
DiagnosticServices_EXTENSION_VERSION = "~3"
180+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
181+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
182+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
183+
XDT_MicrosoftApplicationInsights_Java = "1"
184+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
185+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
186+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
187+
}
188+
189+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
190+
# You can configure the backups to be retained up to an indefinite amount of time.
191+
# Azure storage account and container in the same subscription as the app that you want to back up.
192+
# This module creates a Storage Container to keep the all backup items.
193+
# Backup items - App configuration , File content, Database connected to your app
194+
enable_backup = true
195+
storage_account_name = "stdiagfortesting1"
196+
backup_settings = {
197+
enabled = true
198+
name = "DefaultBackup"
199+
frequency_interval = 1
200+
frequency_unit = "Day"
201+
retention_period_in_days = 90
202+
}
203+
204+
# Regional VNet integration configuration
205+
# Enables you to place the back end of app in a subnet in virtual network in the same region
206+
enable_vnet_integration = true
207+
subnet_id = element(module.vnet.subnet_ids, 0)
208+
209+
# By default App Insight resource is created by this module.
210+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
211+
# Specifies the type of Application by setting up `application_insights_type` with valid string
212+
# Specifies the retention period in days using `retention_in_days`. Default 90.
213+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
214+
app_insights_name = "otkpocshared"
215+
216+
# Adding TAG's to your Azure resources
217+
tags = {
218+
ProjectName = "demo-internal"
219+
Env = "dev"
220+
Owner = "user@example.com"
221+
BusinessUnit = "CORP"
222+
ServiceClass = "Gold"
223+
}
224+
}
225+
```
226+
227+
## Terraform Usage
228+
229+
To run this example you need to execute following Terraform commands
230+
231+
```hcl
232+
terraform init
233+
terraform plan
234+
terraform apply
235+
```
236+
237+
Run `terraform destroy` when you don't need these resources.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Azure App Service (Web Apps) Terraform Module
2+
3+
Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points.
4+
5+
## Module Usage
6+
7+
```hcl
8+
# Azurerm Provider configuration
9+
provider "azurerm" {
10+
features {}
11+
}
12+
13+
module "vnet" {
14+
source = "kumarvna/vnet/azurerm"
15+
version = "2.1.0"
16+
17+
create_resource_group = false
18+
resource_group_name = "rg-shared-westeurope-01"
19+
vnetwork_name = "vnet-shared-hub-westeurope-002"
20+
location = "westeurope"
21+
vnet_address_space = ["10.2.0.0/16"]
22+
create_network_watcher = false
23+
24+
subnets = {
25+
web_subnet = {
26+
subnet_name = "snet-webapp"
27+
subnet_address_prefix = ["10.2.1.0/24"]
28+
delegation = {
29+
name = "testdelegation"
30+
service_delegation = {
31+
name = "Microsoft.Web/serverFarms"
32+
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
33+
}
34+
}
35+
}
36+
}
37+
38+
# Adding TAG's to your Azure resources (Required)
39+
tags = {
40+
ProjectName = "demo-internal"
41+
Env = "dev"
42+
Owner = "user@example.com"
43+
BusinessUnit = "CORP"
44+
ServiceClass = "Gold"
45+
}
46+
}
47+
48+
module "app-service" {
49+
source = "kumarvna/app-service/azurerm"
50+
version = "1.0.0"
51+
52+
# By default, this module will not create a resource group. Location will be same as existing RG.
53+
# proivde a name to use an existing resource group, specify the existing resource group name,
54+
# set the argument to `create_resource_group = true` to create new resrouce group.
55+
resource_group_name = "rg-shared-westeurope-01"
56+
57+
# App service plan setttings and supported arguments. Default name used by module
58+
# To specify custom name use `app_service_plan_name` with a valid name.
59+
# for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
60+
# App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.
61+
service_plan = {
62+
kind = "Windows"
63+
size = "P1v2"
64+
tier = "PremiumV2"
65+
}
66+
67+
# App Service settings and supported arguments
68+
# Backup, connection_string, auth_settings, Storage for mounts are optional configuration
69+
app_service_name = "kumarsmypocproject"
70+
enable_client_affinity = true
71+
72+
# A `site_config` block to setup the application environment.
73+
# Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes`
74+
# Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux`
75+
site_config = {
76+
always_on = true
77+
dotnet_framework_version = "v2.0"
78+
ftps_state = "FtpsOnly"
79+
managed_pipeline_mode = "Integrated"
80+
use_32_bit_worker_process = true
81+
windows_fx_version = "DOTNETCORE|2.1"
82+
}
83+
84+
# (Optional) A key-value pair of Application Settings
85+
app_settings = {
86+
APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0"
87+
APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0"
88+
DiagnosticServices_EXTENSION_VERSION = "~3"
89+
InstrumentationEngine_EXTENSION_VERSION = "disabled"
90+
SnapshotDebugger_EXTENSION_VERSION = "disabled"
91+
XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled"
92+
XDT_MicrosoftApplicationInsights_Java = "1"
93+
XDT_MicrosoftApplicationInsights_Mode = "recommended"
94+
XDT_MicrosoftApplicationInsights_NodeJS = "1"
95+
XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled"
96+
}
97+
98+
# The Backup feature in Azure App Service easily create app backups manually or on a schedule.
99+
# You can configure the backups to be retained up to an indefinite amount of time.
100+
# Azure storage account and container in the same subscription as the app that you want to back up.
101+
# This module creates a Storage Container to keep the all backup items.
102+
# Backup items - App configuration , File content, Database connected to your app
103+
enable_backup = true
104+
storage_account_name = "stdiagfortesting1"
105+
backup_settings = {
106+
enabled = true
107+
name = "DefaultBackup"
108+
frequency_interval = 1
109+
frequency_unit = "Day"
110+
retention_period_in_days = 90
111+
}
112+
113+
# Regional VNet integration configuration
114+
# Enables you to place the back end of app in a subnet in virtual network in the same region
115+
enable_vnet_integration = true
116+
subnet_id = element(module.vnet.subnet_ids, 0)
117+
118+
# By default App Insight resource is created by this module.
119+
# Specify valid resource Id to `application_insights_id` to use existing App Insight
120+
# Specifies the type of Application by setting up `application_insights_type` with valid string
121+
# Specifies the retention period in days using `retention_in_days`. Default 90.
122+
# By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true`
123+
app_insights_name = "otkpocshared"
124+
125+
# Adding TAG's to your Azure resources
126+
tags = {
127+
ProjectName = "demo-internal"
128+
Env = "dev"
129+
Owner = "user@example.com"
130+
BusinessUnit = "CORP"
131+
ServiceClass = "Gold"
132+
}
133+
}
134+
```
135+
136+
## Terraform Usage
137+
138+
To run this example you need to execute following Terraform commands
139+
140+
```hcl
141+
terraform init
142+
terraform plan
143+
terraform apply
144+
```
145+
146+
Run `terraform destroy` when you don't need these resources.

0 commit comments

Comments
 (0)