'Terraform fails to create a 64-bit Azure App Service (Web app)
I am using terraform version 0.15.5 (and also 0.15.4) to provision an Azure Web App resource. The following configuration works fine:
site_config {
http2_enabled = true
always_on = false
use_32_bit_worker_process = true
}
But when I use use_32_bit_worker_process = false to get the script provision a 64-bit web app, it fails and I get the following error message:
2021-06-03T18:06:55.6392592Z [31m│[0m [0m[1m[31mError: [0m[0m[1mError creating App Service "gfdemogatewayapp" (Resource Group "MASKED"): web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>[0m
2021-06-03T18:06:55.6411094Z [31m│[0m [0m
2021-06-03T18:06:55.6426506Z [31m│[0m [0m[0m with azurerm_app_service.gfgatewayapp,
2021-06-03T18:06:55.6427703Z [31m│[0m [0m on main.tf line 274, in resource "azurerm_app_service" "gfgatewayapp":
2021-06-03T18:06:55.6428766Z [31m│[0m [0m 274: resource "azurerm_app_service" "gfgatewayapp" [4m{[0m[0m
2021-06-03T18:06:55.6429584Z [31m│[0m [0m
2021-06-03T18:06:55.6430461Z [31m╵[0m[0m
2021-06-03T18:06:55.6534148Z ##[error]Error: The process '/opt/hostedtoolcache/terraform/0.15.4/x64/terraform' failed with exit code 1
2021-06-03T18:06:55.6548186Z ##[section]Finishing: Terraform approve and apply
Is there something that I am missing or terraform has an issue in provisioning the 64-bit web app resource on Azure?
UPDATE: The full source code The tier is Standard and the SKU size is "F1".
resource "azurerm_app_service_plan" "gfwebappserviceplan" {
name = var.gatewayserviceplanname
location = "${azurerm_resource_group.gf.location}"
resource_group_name = "${azurerm_resource_group.gf.name}"
sku {
tier = var.gatewayserviceplanskutier
size = var.gatewayserviceplanskusize
}
}
resource "azurerm_app_service" "gfgatewayapp" {
name = var.gatewayappname
location = "${azurerm_resource_group.gf.location}"
resource_group_name = "${azurerm_resource_group.gf.name}"
app_service_plan_id = azurerm_app_service_plan.gfwebappserviceplan.id
app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.gfapplicationinsights.instrumentation_key}"
}
site_config {
http2_enabled = true
always_on = false
use_32_bit_worker_process = false
}
}
output "gfgatewayhostname" {
value = "${azurerm_app_service.gfgatewayapp.default_site_hostname}"
description = "Gateway default host name"
}
resource "azurerm_template_deployment" "webapp-corestack" {
# This will make it .NET CORE for Stack property, and add the dotnet core logging extension
name = "AspNetCoreStack"
resource_group_name = "${azurerm_resource_group.gf.name}"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string",
"metadata": {
"description": "The Azure App Service Name"
}
},
"extensionName": {
"type": "string",
"metadata": {
"description": "The Site Extension Name."
}
},
"extensionVersion": {
"type": "string",
"metadata": {
"description": "The Extension Version"
}
}
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"properties": {
"name": "[parameters('siteName')]",
"siteConfig": {
"appSettings": [],
"metadata": [
{
"name": "CURRENT_STACK",
"value": "dotnetcore"
}
]
}
}
},
{
"type": "Microsoft.Web/sites/siteextensions",
"name": "[concat(parameters('siteName'), '/', parameters('extensionName'))]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"properties": {
"version": "[parameters('extensionVersion')]"
}
}
]
}
DEPLOY
parameters = {
"siteName" = azurerm_app_service.gfgatewayapp.name
"extensionName" = "Microsoft.AspNetCore.AzureAppServices.SiteExtension"
"extensionVersion" = "3.1.7"
}
deployment_mode = "Incremental"
depends_on = [azurerm_app_service.gfgatewayapp]
}
Solution 1:[1]
You are getting this error because you are using a F1 tier app service plan. Free or Shared tiers do not have a 64 bit option.
Solution 2:[2]
Since this is the first google result you get when searching for
"AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0"
and that was my error, I will try to help other people that might stumble over this problem.
What I did was migrating a function from azure provider version 2.x to 3.x. Since terraform actually changed the resource type from azurerm_function_app to azurerm_windows_function_app they also changed some properties.
What happened for me was that they added the properties application_insights_key and application_insights_connection_string to the site_config. Before you had to manually (in the app_settings) add a key called APPINSIGHTS_INSTRUMENTATIONKEY.
I used the new setting but forgot to get rid of the manually added key and my function creation was failing with the above (not very verbose if you ask me) error.
Took me a while to figure that out, so that's why I'm sharing this here.
Solution 3:[3]
If setting use_32_bit_worker_process or use_32_bit_worker to true does not help, then try to run terraform with logging. Logging can be enabled by setting the TF_LOG environment variable, e.g.:
$ TF_LOG=debug terraform apply
This will produce a lot of logging, including the HTTP responses from Azure. One of the last logged responses should include more details about the cause. In my case it was because always_on is not supported on the free plan, but is enabled by default:
HTTP/2.0 409 Conflict
<snip>
{"Code":"Conflict","Message":"There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it. [...]}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 54m |
| Solution 2 | MerlinK |
| Solution 3 | Supr |
