Azure App Service (Web Apps) Service Plan
This page shows how to write Terraform and Azure Resource Manager for App Service (Web Apps) Service Plan and write them securely.
azurerm_service_plan (Terraform)
The Service Plan in App Service (Web Apps) can be configured in Terraform with the resource name azurerm_service_plan
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
The following arguments are supported:
name
- (Required) The name which should be used for this Service Plan. Changing this forces a new AppService to be created.location
- (Required) The Azure Region where the Service Plan should exist. Changing this forces a new AppService to be created.os_type
- (Required) The O/S type for the App Services to be hosted in this plan. Possible values includeWindows
,Linux
, andWindowsContainer
.resource_group_name
- (Required) The name of the Resource Group where the AppService should exist. Changing this forces a new AppService to be created.sku_name
- (Required) The SKU for the plan. Possible values includeB1
,B2
,B3
,D1
,F1
,FREE
,I1
,I2
,I3
,I1v2
,I2v2
,I3v2
,P1v2
,P2v2
,P3v2
,P1v3
,P2v3
,P3v3
,S1
,S2
,S3
,SHARED
,PC2
,PC3
,PC4
,EP1
,EP2
,EP3
,WS1
,WS2
, andWS3
,.
NOTE: Isolated SKUs (
I1
,I2
,I3
,I1v2
,I2v2
, andI3v2
) can only be used with App Service Environments
NOTE: Elastic and Consumption SKUs (
PC2
,PC3
,PC4
,EP1
,EP2
, andEP3
) are for use with Function Apps.
app_service_environment_id
- (Optional) The ID of the App Service Environment to create this Service Plan in.
NOTE: Requires an Isolated SKU. Use one of
I1
,I2
,I3
forazurerm_app_service_environment
, orI1v2
,I2v2
,I3v2
forazurerm_app_service_environment_v3
maximum_elastic_worker_count
- (Optional) The maximum number of workers to use in an Elastic SKU Plan. Cannot be set unless using an Elastic SKU.number_of_workers
- (Optional) The number of Workers (instances) to be allocated.per_site_scaling_enabled
- (Optional) Should Per Site Scaling be enabled. Defaults tofalse
.tags
- (Optional) A mapping of tags which should be assigned to the AppService.
In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the Service Plan.kind
- A string representing the Kind of Service Plan.reserved
- Whether this is a reserved Service Plan Type.true
ifos_type
isLinux
, otherwisefalse
.
Explanation in Terraform Registry
Manages an App Service: Service Plan. !> Note: This Resource is coming in version 3.0 of the Azure Provider and is available as an opt-in Beta - more information can be found in the upcoming version 3.0 of the Azure Provider.
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
apiVersion
required - stringextendedLocation
optionalname
optional - stringName of extended location.
kind
optional - stringKind of resource.
location
required - stringResource Location.
name
required - stringName of the App Service plan.
properties
requiredelasticScaleEnabled
optional - booleanServerFarm supports ElasticScale. Apps in this plan will scale as if the ServerFarm was ElasticPremium sku
freeOfferExpirationTime
optional - stringThe time when the server farm free offer expires.
hostingEnvironmentProfile
optionalid
optional - stringResource ID of the App Service Environment.
hyperV
optional - booleanIf Hyper-V container app service plan <code>true</code>, <code>false</code> otherwise.
isSpot
optional - booleanIf <code>true</code>, this App Service Plan owns spot instances.
isXenon
optional - booleanObsolete: If Hyper-V container app service plan <code>true</code>, <code>false</code> otherwise.
kubeEnvironmentProfile
optionalid
optional - stringResource ID of the Kubernetes Environment.
maximumElasticWorkerCount
optional - integerMaximum number of total workers allowed for this ElasticScaleEnabled App Service Plan
perSiteScaling
optional - 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.
reserved
optional - booleanIf Linux app service plan <code>true</code>, <code>false</code> otherwise.
spotExpirationTime
optional - stringThe time when the server farm expires. Valid only if it is a spot server farm.
targetWorkerCount
optional - integerScaling worker count.
targetWorkerSizeId
optional - integerScaling worker size ID.
workerTierName
optional - stringTarget worker tier assigned to the App Service plan.
zoneRedundant
optional - 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.
sku
optionalcapabilities
optional arrayname
optional - stringName of the SKU capability.
reason
optional - stringReason of the SKU capability.
value
optional - stringValue of the SKU capability.
capacity
optional - integerCurrent number of instances assigned to the resource.
family
optional - stringFamily code of the resource SKU.
locations
optional - arrayLocations of the SKU.
name
optional - stringName of the resource SKU.
size
optional - stringSize specifier of the resource SKU.
skuCapacity
optionaldefault
optional - integerDefault number of workers for this App Service plan SKU.
elasticMaximum
optional - integerMaximum number of Elastic workers for this App Service plan SKU.
maximum
optional - integerMaximum number of workers for this App Service plan SKU.
minimum
optional - integerMinimum number of workers for this App Service plan SKU.
scaleType
optional - stringAvailable scale configurations for an App Service plan.
tier
optional - stringService tier of the resource SKU.
tags
optional - stringResource tags.
type
required - string