Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF doesn't report underlying error messages up to console - get '<nil>' instead #6796

Closed
brandonh-msft opened this issue May 6, 2020 · 7 comments
Labels
bug service/app-service upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR v/2.x (legacy)

Comments

@brandonh-msft
Copy link

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=<nil> <nil>

  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.

@sebader
Copy link
Contributor

sebader commented May 6, 2020

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

@jpovey
Copy link
Contributor

jpovey commented Jun 5, 2020

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}

@neil-yechenwei
Copy link
Contributor

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

@mybayern1974 mybayern1974 added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Jul 27, 2020
@boldandbusted
Copy link

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

@ryepup
Copy link
Contributor

ryepup commented Dec 24, 2020

Just ran into this on v2.39.0.

If I do a standard terraform apply I get this logs:

$ terraform apply
...
Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_function_app.func: Creating...
azurerm_function_app.func: Still creating... [10s elapsed]

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

  on main.tf line 36, in resource "azurerm_function_app" "func":
  36: resource "azurerm_function_app" "func" {

If I run again with debug logs, I get a very descriptive error message from azure as JSON in the logs

$ TF_LOG=DEBUG terraform apply
... much more output...
2020-12-24T10:22:16.285-0500 [DEBUG] plugin.terraform-provider-azurerm_v2.39.0_x5: $JSON_ERROR_MESSAGE
2020/12/24 10:22:16 [DEBUG] azurerm_function_app.func: apply errored, but we're indicating that via the Error pointer rather than returning it: web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>
... much more output ...

Extracting that $JSON_ERROR_MESSAGE (and re-formatting) gave me something actionable:

{
  "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
}

I think this may have been the cause of #1271.

@katbyte
Copy link
Collaborator

katbyte commented Jul 19, 2023

I am going to close this because the azurerm_app_service has been superseded by the azurerm_linux_web_app and azurerm_windows_web_app resources.

If this is still an issue with v3.x of the provider and the new resources do let us know by opening a new issue, thanks!

@katbyte katbyte closed this as completed Jul 19, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/app-service upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR v/2.x (legacy)
Projects
None yet
Development

No branches or pull requests

10 participants