Terraform-provider-azurerm: TF doesn't report underlying error messages up to console - get '<nil>' instead

Created on 6 May 2020  路  4Comments  路  Source: terraform-providers/terraform-provider-azurerm

Terraform Version info

Terraform v0.12.24

  • provider.azurerm v2.8.0

I am trying to build an Azure App Service Environment with a _Linux_ App Service Plan in it.

This is proving to be difficult, as the same syntax one uses to define a Linux ASP:

resource "azurerm_app_service_plan" "fxnapp" {
  name                = var.baseName
  location            = var.location
  resource_group_name = azurerm_resource_group.fxnrg.name
  kind                = "Linux" #Required for Linux ASP
  reserved            = true    #Required for Linux ASP

  sku {
    tier = "PremiumV2"
    size = "P3v2"
  }
}

and that which works for a _Windows_ ASP in the ASE:

resource "azurerm_app_service_plan" "windows_fxnapp" {
  name                       = "${var.baseName}-win"
  location                   = var.location
  resource_group_name        = azurerm_resource_group.winrg.name
  app_service_environment_id = azurerm_app_service_environment.fxnase.id
  sku {
    tier     = "Isolated"  # Required for ASP w/in ASE
    size     = "I3"        # Required for ASP w/in ASE
    capacity = 1           # Required for ASP w/in ASE
  }
}

don't seem to work:

resource "azurerm_app_service_plan" "linux_fxnapp" {
  name                = "${var.baseName}-lx"
  location            = var.location
  resource_group_name = azurerm_resource_group.lxrg.name
  kind                = "Linux"
  reserved            = true

  sku {
    tier     = "Isolated"
    size     = "I3"
    capacity = 1
  }
}

However, the point of this issue is to focus on the developer experience when working w/ this.

Here's what I get from the command line tf apply:

~~~
rror: Error creating/updating App Service Plan "xxxxx" (Resource Group "xxxxxx"): web.AppServicePlansClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=

on functions\appserviceenvironment-i3\main.tf line 91, in resource "azurerm_app_service_plan" "linux_fxnapp":
91: resource "azurerm_app_service_plan" "linux_fxnapp" {
~~~

Yet the underlying DEBUG output shows:

~
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Web/serverfarms/xxxx?api-version=2019-08-01:
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: HTTP/2.0 409 Conflict
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Content-Length: 789
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Cache-Control: no-cache
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Content-Type: application/json; charset=utf-8
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Date: Wed, 06 May 2020 16:38:35 GMT
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Expires: -1
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Pragma: no-cache
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Server: Microsoft-IIS/10.0
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: Strict-Transport-Security: max-age=31536000; includeSubDomains
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Aspnet-Version: 4.0.30319
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Content-Type-Options: nosniff
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Ms-Correlation-Request-Id: f218ebba-4f68-5118-db7e-3cc04acb445c
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Ms-Ratelimit-Remaining-Subscription-Writes: 1197
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Ms-Request-Id: 4a295092-8255-47dd-a014-67cabcf4085a
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Ms-Routing-Request-Id: WESTUS:20200506T163836Z:4a295092-8255-47dd-a014-67cabcf4085a
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: X-Powered-By: ASP.NET
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe:
2020-05-06T09:38:37.110-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.8.0_x5.exe: {"Code":"Conflict","Message":"The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764","Target":null,"Details":[{"Message":"The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764"},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"04114","MessageTemplate":"The pricing tier '{0}' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764","Parameters":["Isolated"],"Code":"Conflict","Message":"The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764"}}],"Innererror":null}
~

{
    "Code": "Conflict",
    "Message": "The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764",
    "Target": null,
    "Details": [
        {
            "Message": "The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764"
        },
        {
            "Code": "Conflict"
        },
        {
            "ErrorEntity": {
                "ExtendedCode": "04114",
                "MessageTemplate": "The pricing tier '{0}' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764",
                "Parameters": [
                    "Isolated"
                ],
                "Code": "Conflict",
                "Message": "The pricing tier 'Isolated' is not allowed in this resource group. Use this link to learn more: http://go.microsoft.com/fwlink/?LinkId=825764"
            }
        }
    ],
    "Innererror": null
}

Which is infinitely more useful than what the console reported back.
We should be reporting this message content back up instead of forcing devs to set env vars and parse logs to find the real problem.

bug servicapp-service upstream-microsoft

All 4 comments

I have seen the same behavior when App Service Plan (not ASE) provisioning or scaling out failed due to lack of capacity.

I have experienced same issue when applying a azurerm_function_app

Error: web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>

  on main.tf line 117, in resource "azurerm_function_app" "fa":
 117: resource "azurerm_function_app" "fa" {
2020-06-03T11:44:40.302Z [DEBUG] plugin.terraform-provider-azurerm_v2.1.0_x5: X-Powered-By: ASP.NET
2020-06-03T11:44:40.302Z [DEBUG] plugin.terraform-provider-azurerm_v2.1.0_x5: 
2020-06-03T11:44:40.302Z [DEBUG] plugin.terraform-provider-azurerm_v2.1.0_x5: {"Code":"Conflict","Message":"There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails ","Target":null,"Details":[{"Message":"There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails "},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"01020","MessageTemplate":"There was a conflict. {0}","Parameters":["AlwaysOn cannot be set for this site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails "],"Code":"Conflict","Message":"There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails "}}],"Innererror":null}

Thanks for opening this issue. After checked, seems there is no error message in response when it failed to provision app service plan. So filed an issue on Azure/azure-rest-api-specs#10210

I got this sort of scenario, as well. Turning TF_LOG=TRACE, found this was the root:

2020-08-27T15:39:32.707-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.24.0_x5: {"Code":"Conflict","Message":"There was a conflict. 64 Bit
 worker processes cannot be used for the site as the plan does not allow it. For more information on pricing and features, please see: https:
//aka.ms/appservicepricingdetails ","Target":null,"Details":[{"Message":"There was a conflict. 64 Bit worker processes cannot be used for the
 site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails "},{"C
ode":"Conflict"},{"ErrorEntity":{"ExtendedCode":"01020","MessageTemplate":"There was a conflict. {0}","Parameters":["64 Bit worker processes
cannot be used for the site as the plan does not allow it. For more information on pricing and features, please see: https://aka.ms/appservic
epricingdetails "],"Code":"Conflict","Message":"There was a conflict. 64 Bit worker processes cannot be used for the site as the plan does no
t allow it. For more information on pricing and features, please see: https://aka.ms/appservicepricingdetails "}}],"Innererror":null}
2020/08/27 15:39:32 [DEBUG] azurerm_app_service.main: apply errored, but we're indicating that via the Error pointer rather than returning it
: Error creating App Service "test-appservice-ftw" (Resource Group "test-resources"): web.AppsClient#CreateOrUpdate: Failure sending request:
 StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>

I'd prefer to see this error, rather than have it buried under "Service returned an error. Status= " :)

Also, FWIW, the URL report for my error is wrong. So, insult + injury. :D

Was this page helpful?
0 / 5 - 0 ratings