Azure Terraform error: Service returned an error. Status=<nil> <nil> when creating an Azure Web App

Share on:

Hi,

Today I was tinkering around with Azure and Terraform. I’ve been working on creating a Azure Web App based off of Linux. However I ran into the following error:

Failure sending request: StatusCode=0 — Original Error: autorest/azure: Service returned an error. Status=

This was caused by two things. Per the docs, the always_on option should be false by default, but it actually defaults to true. Because I was using the F1 SKU, which is free, this failed as it does not support always_on and it must be a 32 bit worker as well so I also set user_32_bit_worker to true just to be sure.

Here’s the code:

 1resource "azurerm_service_plan" "asp-webapp-free" {
 2  name                = "test-asp-webapp-free"
 3  resource_group_name = azurerm_resource_group.rg-dw.name
 4  location            = azurerm_resource_group.rg-dw.location
 5  os_type              = "Linux"
 6  sku_name             = "F1"
 7  tags = {
 8    "usage"       = "learning"
 9    "environment" = "development"
10    "owner"       = "you"
11  }
12}
13
14resource "azurerm_linux_web_app" "test-webapp-01" {
15  name                = "test-webapp-01"
16  resource_group_name = azurerm_resource_group.rg-dw.name
17  location            = azurerm_resource_group.rg-dw.location
18  service_plan_id     = azurerm_service_plan.asp-webapp-free.id
19  site_config {
20    application_stack {
21      node_version      = "16-lts"
22    }
23    always_on         = false // Required for F1 plan (even though docs say that it defaults to false)
24    use_32_bit_worker = true // Required for F1 plan
25  }
26  tags = {
27    "usage"       = "learning"
28    "environment" = "development"
29    "owner"       = "you"
30  }
31}

Thanks for reading and hope it helps someone.