Azure App Service (Web Apps) Environment

This page shows how to write Terraform for App Service (Web Apps) Environment and write them securely.

azurerm_app_service_environment (Terraform)

The Environment in App Service (Web Apps) can be configured in Terraform with the resource name azurerm_app_service_environment. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

app_service_environment_test.tf#L25
resource "azurerm_app_service_environment" "example_I1" {
  name                         = "example-ase"
  subnet_id                    = azurerm_subnet.ase.id
  pricing_tier                 = "I1"
  front_end_scale_factor       = 10
  internal_load_balancing_mode = "Web, Publishing"
app_service_environment_test.tf#L25
resource "azurerm_app_service_environment" "example_I1" {
  name                         = "example-ase"
  subnet_id                    = azurerm_subnet.ase.id
  pricing_tier                 = "I1"
  front_end_scale_factor       = 10
  internal_load_balancing_mode = "Web, Publishing"
ase-main.tf#L1
resource "azurerm_app_service_environment" "example" {
  name                         = "example-ase"
  subnet_id                    = azurerm_subnet.ase.id
  pricing_tier                 = "I2"
  front_end_scale_factor       = 10
  internal_load_balancing_mode = "Web, Publishing"
resource.tf#L1
resource "azurerm_app_service_environment" "ase" {
    name                            = var.res_ase_name
    subnet_id                       = var.res_ase_subnet_id
    pricing_tier                    = var.res_ase_pricing_tier
    front_end_scale_factor          = var.res_ase_fe_scale
    resource_group_name             = var.res_rg_name
main.tf#L4
resource "azurerm_app_service_environment" "ase" {
  name                         = "example-ase"
  subnet_id                    = var.aseSubnetId
  internal_load_balancing_mode = "Web, Publishing"

  cluster_setting {
main.tf#L1
resource "azurerm_app_service_environment" "app_service_environment" {
  name                         = var.app_service_environment_name
  resource_group_name          = var.resource_group_name
  subnet_id                    = var.subnet_id
  pricing_tier                 = var.ase_pricing_tier
  front_end_scale_factor       = var.front_end_scale_factor
main.tf#L1
resource "azurerm_app_service_environment" "app_service_environment" {
  name                         = var.app_service_environment_name
  resource_group_name          = var.resource_group_name
  subnet_id                    = var.subnet_id
  pricing_tier                 = var.ase_pricing_tier
  front_end_scale_factor       = var.front_end_scale_factor
main.tf#L1
resource "azurerm_app_service_environment" "example" {
  name                         = var.name
  subnet_id                    = module.subnet.azurerm_subnet.example.id
  pricing_tier                 = var.pricing_tier
  front_end_scale_factor       = var.front_end_scale
  internal_load_balancing_mode = var.internal_load_balance
main.tf#L7
resource "azurerm_app_service_environment" "this" {
  front_end_scale_factor       = var.front_end_scale_factor
  internal_load_balancing_mode = var.internal_load_balancing_mode
  name                         = var.name
  pricing_tier                 = var.pricing_tier
  subnet_id                    = var.subnet_id
main.tf#L29
resource "azurerm_app_service_environment" "function" {
  name                         = "consul-function-env"
  subnet_id                    = azurerm_subnet.consul.id
  pricing_tier                 = "I1"
  front_end_scale_factor       = 5
  internal_load_balancing_mode = "None"

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an App Service Environment.

Tips: Best Practices for The Other Azure App Service (Web Apps) Resources

In addition to the azurerm_app_service, Azure App Service (Web Apps) has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_app_service

Ensure your App Service is accessible via HTTPS only

It is better to configure the App Service to be accessible via HTTPS only. By default, both HTTP and HTTPS are available.

risk-label

azurerm_function_app

Ensure to enable authentication to prevent anonymous request being accepted

It is better to enable authentication to prevent anonymous requests and ensure all communications in the application are authenticated.

Review your Azure App Service (Web Apps) settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Azure Resource Manager Example

Azure Resource Manager code does not have the related resource.

Frequently asked questions

What is Azure App Service (Web Apps) Environment?

Azure App Service (Web Apps) Environment is a resource for App Service (Web Apps) of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure App Service (Web Apps) Environment?

For Terraform, the gilyas/infracost, infracost/infracost and jactools/demo-terraform source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.