Azure App Service (Web Apps) Plan
This page shows how to write Terraform and Azure Resource Manager for App Service (Web Apps) Plan and write them securely.
azurerm_app_service_plan (Terraform)
The Plan in App Service (Web Apps) can be configured in Terraform with the resource name azurerm_app_service_plan. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_app_service_plan" "standard_s1" {
name = "api-appserviceplan-pro"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
kind = "Windows"
reserved = false
resource "azurerm_app_service_plan" "app_asp" {
name = format("%s-%s", var.app_rg_name, "asp")
resource_group_name = var.app_rg_name
location = var.rg_location
is_xenon = false
kind = "linux"
resource "azurerm_app_service_plan" "web-app" {
name = "WebAppServicePlan"
location = azurerm_resource_group.post-office-rg.location
resource_group_name = azurerm_resource_group.post-office-rg.name
kind = "app"
reserved = true
resource "azurerm_app_service_plan" "app_service_plan_linux" {
name = "bjdhosting-linux"
resource_group_name = data.azurerm_resource_group.ase.name
location = data.azurerm_resource_group.ase.location
kind = "Linux"
reserved = true
resource "azurerm_app_service_plan" "standard_s1" {
name = "api-appserviceplan-pro"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
kind = "Windows"
reserved = false
resource "azurerm_app_service_plan" "primary_plan" {
name = "primary-plan"
resource_group_name = azurerm_resource_group.resource_group.name
location = random_shuffle.regions-with-az.result[0]
kind = "functionapp"
reserved = true
resource "azurerm_app_service_plan" "cloudskillswebapp-plan" {
name = "cloudskillswebapp-plan"
location = var.location
resource_group_name = var.RG
sku {
resource "azurerm_app_service_plan" "plan" {
name = "appserviceplan-linux"
location = var.location
resource_group_name = basename(azurerm_resource_group.rg.id)
kind = "Linux"
reserved = true
resource "azurerm_app_service_plan" "poc" {
name = "api-appserviceplan"
location = var.resource-group-location
resource_group_name = var.resource-group-name
kind = "Linux"
reserved = true
resource "azurerm_app_service_plan" "app_sp" {
name = "myappserviceplan"
resource_group_name = "myresourcegroup"
sku {
tier = "Standard"
size = "S1"
Parameters
-
app_service_environment_idoptional - string -
idoptional computed - string -
is_xenonoptional - bool -
kindoptional - string -
locationrequired - string -
maximum_elastic_worker_countoptional computed - number -
maximum_number_of_workersoptional computed - number -
namerequired - string -
per_site_scalingoptional - bool -
reservedoptional - bool -
resource_group_namerequired - string -
tagsoptional - map from string to string -
skulist block -
timeoutssingle block
Explanation in Terraform Registry
Manages an App Service Plan component.
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.
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.
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.
Microsoft.Web/serverfarms (Azure Resource Manager)
The serverfarms in Microsoft.Web can be configured in Azure Resource Manager with the resource name Microsoft.Web/serverfarms. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"resourceType": "Microsoft.Web/serverfarms",
"sku": {
"name": "F1",
"tier": "Free"
},
"capacity": {
"resourceType": "Microsoft.Web/serverfarms",
"sku": {
"name": "F1",
"tier": "Free"
},
"capacity": {
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('aseLocation')]",
"properties": {
"name": "[parameters('CMappServicePlanName')]",
"hostingEnvironmentProfile": {
"id": "[resourceId('Microsoft.Web/hostingEnvironments',parameters('appServiceEnvironmentName'))]"
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd001_name')]",
"location": "West US",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd071_name')]",
"location": "East US",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd091_name')]",
"location": "East US",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd061_name')]",
"location": "East US",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd071_name')]",
"location": "East US 2",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd071_name')]",
"location": "West US 2",
"sku": {
"name": "P3v2",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_chieuannhieusd011_name')]",
"location": "West US",
"sku": {
"name": "P3v2",
Parameters
apiVersionrequired - stringextendedLocationoptionalnameoptional - stringName of extended location.
kindoptional - stringKind of resource.
locationrequired - stringResource Location.
namerequired - stringName of the App Service plan.
propertiesrequiredelasticScaleEnabledoptional - booleanServerFarm supports ElasticScale. Apps in this plan will scale as if the ServerFarm was ElasticPremium sku
freeOfferExpirationTimeoptional - stringThe time when the server farm free offer expires.
hostingEnvironmentProfileoptionalidoptional - stringResource ID of the App Service Environment.
hyperVoptional - booleanIf Hyper-V container app service plan <code>true</code>, <code>false</code> otherwise.
isSpotoptional - booleanIf <code>true</code>, this App Service Plan owns spot instances.
isXenonoptional - booleanObsolete: If Hyper-V container app service plan <code>true</code>, <code>false</code> otherwise.
kubeEnvironmentProfileoptionalidoptional - stringResource ID of the Kubernetes Environment.
maximumElasticWorkerCountoptional - integerMaximum number of total workers allowed for this ElasticScaleEnabled App Service Plan
perSiteScalingoptional - booleanIf <code>true</code>, apps assigned to this App Service plan can be scaled independently. If <code>false</code>, apps assigned to this App Service plan will scale to all instances of the plan.
reservedoptional - booleanIf Linux app service plan <code>true</code>, <code>false</code> otherwise.
spotExpirationTimeoptional - stringThe time when the server farm expires. Valid only if it is a spot server farm.
targetWorkerCountoptional - integerScaling worker count.
targetWorkerSizeIdoptional - integerScaling worker size ID.
workerTierNameoptional - stringTarget worker tier assigned to the App Service plan.
zoneRedundantoptional - booleanIf <code>true</code>, this App Service Plan will perform availability zone balancing. If <code>false</code>, this App Service Plan will not perform availability zone balancing.
skuoptionalcapabilitiesoptional arraynameoptional - stringName of the SKU capability.
reasonoptional - stringReason of the SKU capability.
valueoptional - stringValue of the SKU capability.
capacityoptional - integerCurrent number of instances assigned to the resource.
familyoptional - stringFamily code of the resource SKU.
locationsoptional - arrayLocations of the SKU.
nameoptional - stringName of the resource SKU.
sizeoptional - stringSize specifier of the resource SKU.
skuCapacityoptionaldefaultoptional - integerDefault number of workers for this App Service plan SKU.
elasticMaximumoptional - integerMaximum number of Elastic workers for this App Service plan SKU.
maximumoptional - integerMaximum number of workers for this App Service plan SKU.
minimumoptional - integerMinimum number of workers for this App Service plan SKU.
scaleTypeoptional - stringAvailable scale configurations for an App Service plan.
tieroptional - stringService tier of the resource SKU.
tagsoptional - stringResource tags.
typerequired - string
Frequently asked questions
What is Azure App Service (Web Apps) Plan?
Azure App Service (Web Apps) Plan 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) Plan?
For Terraform, the gilyas/infracost, DFE-Digital/claim-additional-payments-for-teaching-qts-api and iamprovidence/PostOffice source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the brwilkinson/ADFL, brwilkinson/AzureDeploymentFramework and mangleshvyas/Sitecore9 source code examples are useful. See the Azure Resource Manager Example section for further details.