This is the web server farm (App Service Plan) resource module for the Azure Verified Modules library. This module deploys an App Service Plan (ASP). It leverages the AzureRM provider and sets a number of initial defaults to minimize the overall inputs for simple configurations.
Important
As the overall AVM framework is not GA (generally available) yet - the CI framework and test automation is not fully functional and implemented across all supported languages yet - breaking changes are expected, and additional customer feedback is yet to be gathered and incorporated. Hence, modules WILL NOT be published at version 1.0.0 or higher at this time.
However, it is important to note that this DOES NOT mean that this module cannot be consumed and utilized. It CAN be leveraged in all types of environments (dev, test, prod etc.). Consumers can treat this just like any other IaC module and raise issues or feature requests against it as they learn from the usage of the module. Consumers should also read the release notes for each version, if considering updating to a more recent version of a module to see if there are any considerations or breaking changes etc.
The following requirements are needed by this module:
The following resources are used by this module:
- azapi_resource.diagnostic_setting (resource)
- azapi_resource.lock (resource)
- azapi_resource.role_assignment (resource)
- azapi_resource.this (resource)
- modtm_telemetry.telemetry (resource)
- random_uuid.telemetry (resource)
- azapi_client_config.telemetry (data source)
- azapi_client_config.this (data source)
- azapi_resource_action.flex_consumption_geo_regions (data source)
- modtm_module_source.telemetry (data source)
The following input variables are required:
Description: The location where the resources will be deployed.
Type: string
Description: The name of the this resource.
Type: string
Description: The operating system type of the service plan. Possible values are Windows, Linux or WindowsContainer.
Type: string
Description: The resource ID of the resource group in which to create this resource.
Type: string
The following input variables are optional (have default values):
Description: Optional: The ID of the App Service Environment.
Type: string
Default: null
Description: A map of diagnostic settings to create on the App Service Environment (ASE). The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
name- (Optional) The name of the diagnostic setting. One will be generated if not set, however this will not be unique if you want to create multiple diagnostic setting resources.log_categories- (Optional) A set of log categories to send to the log analytics workspace. Defaults to[].log_groups- (Optional) A set of log groups to send to the log analytics workspace. Defaults to["allLogs"].metric_categories- (Optional) A set of metric categories to send to the log analytics workspace. Defaults to["AllMetrics"].log_analytics_destination_type- (Optional) The destination type for the diagnostic setting. Possible values areDedicatedandAzureDiagnostics. Defaults toDedicated.workspace_resource_id- (Optional) The resource ID of the log analytics workspace to send logs and metrics to.storage_account_resource_id- (Optional) The resource ID of the storage account to send logs and metrics to.event_hub_authorization_rule_resource_id- (Optional) The resource ID of the event hub authorization rule to send logs and metrics to.event_hub_name- (Optional) The name of the event hub. If none is specified, the default event hub will be selected.marketplace_partner_resource_id- (Optional) The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs.
Type:
map(object({
name = optional(string, null)
logs = optional(set(object({
category = optional(string, null)
category_group = optional(string, null)
enabled = optional(bool, true)
retention_policy = optional(object({
days = optional(number, 0)
enabled = optional(bool, false)
}), {})
})), [])
metrics = optional(set(object({
category = optional(string, null)
enabled = optional(bool, true)
retention_policy = optional(object({
days = optional(number, 0)
enabled = optional(bool, false)
}), {})
})), [])
log_analytics_destination_type = optional(string, "Dedicated")
workspace_resource_id = optional(string, null)
storage_account_resource_id = optional(string, null)
event_hub_authorization_rule_resource_id = optional(string, null)
event_hub_name = optional(string, null)
marketplace_partner_resource_id = optional(string, null)
}))Default: {}
Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.
Type: bool
Default: true
Description: Optional: A list of install scripts to run on the Managed Instance App Service Plan. Only applicable when os_type is WindowsManagedInstance.
name- (Required) The name of the install script (e.g."FontInstaller").source- (Required) The source configuration for the install script.type- (Optional) The type of the source. Defaults to"RemoteAzureBlob".source_uri- (Required) The URI of the install script package (e.g. a blob URI to a.zipfile).
Type:
list(object({
name = string
source = object({
type = optional(string, "RemoteAzureBlob")
source_uri = string
})
}))Default: null
Description: Controls the Resource Lock configuration for this resource. The following properties can be specified:
kind- (Required) The type of lock. Possible values are\"CanNotDelete\"and\"ReadOnly\".name- (Optional) The name of the lock. If not specified, a name will be generated based on thekindvalue. Changing this forces the creation of a new resource.
Type:
object({
kind = string
name = optional(string, null)
})Default: null
Description: Controls the managed identity configuration on this resource. The following properties can be specified:
system_assigned- (Optional) Specifies if the System Assigned Managed Identity should be enabled.user_assigned_resource_ids- (Optional) Specifies a list of User Assigned Managed Identity resource IDs to be assigned to this resource.
Type:
object({
system_assigned = optional(bool, false)
user_assigned_resource_ids = optional(set(string), [])
})Default: {}
Description: The maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan.
Type: number
Default: 3
Description: Should per site scaling be enabled for this App Service Plan.
Type: bool
Default: false
Description: Optional: The default identity configuration for the Managed Instance App Service Plan. Only applicable when os_type is WindowsManagedInstance.
identity_type- (Optional) The type of the identity. Defaults to"UserAssigned".user_assigned_identity_resource_id- (Required) The resource ID of the user-assigned managed identity to use as the plan default identity.
Type:
object({
identity_type = optional(string, "UserAssigned")
user_assigned_identity_resource_id = string
})Default: null
Description: Defaults to false. Should elastic scale be enabled for this App Service Plan. Only set to true if deploying a Premium or Elastic Premium SKU.
Type: bool
Default: false
Description: Optional: Whether RDP is enabled for the Managed Instance App Service Plan. Only applicable when os_type is WindowsManagedInstance. Set to null for non-managed instance plans. A Bastion host with must be deployed in the virtual network for RDP connectivity to work.
Type: bool
Default: null
Description: Optional: A list of registry adapters associated with this App Service Plan. Only applicable when os_type is WindowsManagedInstance.
registry_key- (Required) Registry key for the adapter. The registry key must start withHKEY_LOCAL_MACHINE,HKEY_CURRENT_USER, orHKEY_USERSand contain at least one forward slash (e.g.HKEY_LOCAL_MACHINE/SOFTWARE/MyApp/Config).type- (Required) Type of the registry adapter. Possible values are"DWORD"or"String".key_vault_secret_reference- (Required) Key vault reference to the value that will be placed in the registry location.secret_uri- (Required) The URI of the Key Vault secret.
Type:
list(object({
registry_key = string
type = string
key_vault_secret_reference = object({
secret_uri = string
})
}))Default: null
Description: The retry configuration for azapi resources. The following properties can be specified:
error_message_regex- (Required) A list of regular expressions to match against error messages. If any match, the request will be retried.interval_seconds- (Optional) The base number of seconds to wait between retries. Default is10.max_interval_seconds- (Optional) The maximum number of seconds to wait between retries. Default is180.
Type:
object({
error_message_regex = optional(list(string), ["ScopeLocked"])
interval_seconds = optional(number, null)
max_interval_seconds = optional(number, null)
})Default: null
Description: A map of role assignments to create on the resource. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
role_definition_id_or_name- The ID or name of the role definition to assign to the principal.principal_id- The ID of the principal to assign the role to.description- (Optional) The description of the role assignment.skip_service_principal_aad_check- (Optional) No effect when using AzAPI. Defaults to false.condition- (Optional) The condition which will be used to scope the role assignment.condition_version- (Optional) The version of the condition syntax. Leave asnullif you are not using a condition, if you are then valid values are2.0.delegated_managed_identity_resource_id- (Optional) The delegated Azure Resource Id which contains a Managed Identity. Changing this forces a new resource to be created. This field is only used in cross-tenant scenario.principal_type- (Optional) The type of theprincipal_id. Possible values areUser,GroupandServicePrincipal. It is necessary to explicitly set this attribute when creating role assignments if the principal creating the assignment is constrained by ABAC rules that filters on the PrincipalType attribute.
Note: only set
skip_service_principal_aad_checkto true if you are assigning a role to a service principal.
Type:
map(object({
role_definition_id_or_name = string
principal_id = string
description = optional(string, null)
skip_service_principal_aad_check = optional(bool, false)
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
}))Default: {}
Description: The resource type for the server farm. Defaults to Microsoft.Web/serverfarms.
Type: string
Default: "Microsoft.Web/serverfarms@2025-03-01"
Description: The SKU name of the service plan. Defaults to P1v2.
Type: string
Default: "P1v2"
Description: Optional: A list of storage mounts to configure on the App Service Plan. Only applicable when os_type is WindowsManagedInstance.
name- (Required) The name of the storage mount (e.g."g-drive").type- (Optional) The type of the storage mount. Defaults to"LocalStorage".source- (Optional) The source of the storage mount. Defaults to"".destination_path- (Required) The destination path for the storage mount (e.g."G:\\").credentials_key_vault_reference- (Optional) A Key Vault reference for storage credentials.secret_uri- (Required) The URI of the Key Vault secret.
Type:
list(object({
name = string
type = optional(string, "LocalStorage")
source = optional(string, "")
destination_path = string
credentials_key_vault_reference = optional(object({
secret_uri = optional(string)
}), {})
}))Default: null
Description: Tags of the resource.
Type: map(string)
Default: null
Description: The timeout configuration for azapi resources. The following properties can be specified:
create- (Optional) The timeout for create operations e.g."30m","1h".delete- (Optional) The timeout for delete operations e.g."30m","1h".read- (Optional) The timeout for read operations e.g."30m","1h".update- (Optional) The timeout for update operations e.g."30m","1h".
Type:
object({
create = optional(string, null)
delete = optional(string, null)
read = optional(string, null)
update = optional(string, null)
})Default: null
Description: Optional: The resource ID of the subnet to integrate the App Service Plan with. This enables VNet integration for the plan.
Type: string
Default: null
Description: The number of workers to allocate for this App Service Plan. Defaults to 3, which is the recommended minimum for production workloads.
Type: number
Default: 3
Description: Should zone balancing be enabled for this App Service Plan? Defaults to true.
Note: when sku_name = "FC1" (Flex Consumption), zone redundancy is only available in Azure regions that advertise the FCZONEREDUNDANCY capability. In regions that do not support it, this module fails early with a precondition error listing the supported regions. Set this to false to deploy FC1 in an unsupported region.
Type: bool
Default: true
The following outputs are exported:
Description: Name of the app service plan
Description: Resource id of the app service plan
The following Modules are called:
Source: Azure/avm-utl-interfaces/azure
Version: 0.5.0
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.