terraform-provider-azurerm: azurerm_log_analytics_solution - Failure responding to request: StatusCode=404 ... error: invalid character 'S' looking for beginning of value

Terraform Version

Terraform v0.11.7

  • provider.azurerm v1.12.0

Affected Resource(s)

azurerm_log_analytics_solution

Terraform Configuration Files

resource "azurerm_resource_group" "monitor_rg" {
  name     = "acctestRG-01"
  location = "NorthEurope"
  provider = "azurerm.default"
}

resource "azurerm_log_analytics_workspace" "acctest_la" {
  name                = "acctest-01"
  sku                 = "Free"
  location            = "westeurope"
  resource_group_name = "${azurerm_resource_group.monitor_rg.name}"
  provider            = "azurerm.default"
}

resource "azurerm_log_analytics_solution" "aks_s" {
  solution_name         = "Containers"
  workspace_resource_id = "${azurerm_log_analytics_workspace.acctest_la.id}"
  workspace_name        = "${azurerm_log_analytics_workspace.acctest_la.name}"
  location              = "westeurope"
  resource_group_name   = "${azurerm_resource_group.monitor_rg.name}"
  provider              = "azurerm.default"

  plan {
    publisher = "Microsoft"
    product   = "OMSGallery/Containers"
  }
}

Debug Output

C:\Temp\aitest> terraform apply --var-file=“.\terraform.tfvars”

An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:

  • create

Terraform will perform the following actions:

  • azurerm_log_analytics_solution.aks_s id: <computed> location: “westeurope” plan.#: “1” plan.0.name: <computed> plan.0.product: “OMSGallery/Containers” plan.0.publisher: “Microsoft” resource_group_name: “acctestRG-01” solution_name: “Containers” workspace_name: “acctest-01” workspace_resource_id: “${azurerm_log_analytics_workspace.acctest_la.id}”

  • azurerm_log_analytics_workspace.acctest_la id: <computed> location: “westeurope” name: “acctest-01” portal_url: <computed> primary_shared_key: <computed> resource_group_name: “acctestRG-01” retention_in_days: <computed> secondary_shared_key: <computed> sku: “Free” tags.%: <computed> workspace_id: <computed>

  • azurerm_resource_group.monitor_rg id: <computed> location: “northeurope” name: “acctestRG-01” tags.%: <computed>

Plan: 3 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_resource_group.monitor_rg: Creating… location: “” => “northeurope” name: “” => “acctestRG-01” tags.%: “” => “<computed>” azurerm_resource_group.monitor_rg: Creation complete after 0s (ID: /subscriptions/<…>/resourceGroups/acctestRG-01) azurerm_log_analytics_workspace.acctest_la: Creating… location: “” => “westeurope” name: “” => “acctest-01” portal_url: “” => “<computed>” primary_shared_key: “<sensitive>” => “<sensitive>” resource_group_name: “” => “acctestRG-01” retention_in_days: “” => “<computed>” secondary_shared_key: “<sensitive>” => “<sensitive>” sku: “” => “Free” tags.%: “” => “<computed>” workspace_id: “” => “<computed>” azurerm_log_analytics_workspace.acctest_la: Still creating… (10s elapsed) azurerm_log_analytics_workspace.acctest_la: Still creating… (20s elapsed) azurerm_log_analytics_workspace.acctest_la: Still creating… (30s elapsed) azurerm_log_analytics_workspace.acctest_la: Still creating… (40s elapsed) azurerm_log_analytics_workspace.acctest_la: Still creating… (50s elapsed) azurerm_log_analytics_workspace.acctest_la: Still creating… (1m0s elapsed) azurerm_log_analytics_workspace.acctest_la: Creation complete after 1m5s (ID: /subscriptions/<…>-…rationalinsights/workspaces/acctest-01) azurerm_log_analytics_solution.aks_s: Creating… location: “” => “westeurope” plan.#: “” => “1” plan.0.name: “” => “<computed>” plan.0.product: “” => “OMSGallery/Containers” plan.0.publisher: “” => “Microsoft” resource_group_name: “” => “acctestRG-01” solution_name: “” => “Containers” workspace_name: “” => “acctest-01” workspace_resource_id: “” => “/subscriptions/<…>/resourcegroups/acctestrg-01/providers/microsoft.operationalinsights/workspaces/acctest-01”

Error: Error applying plan:

1 error(s) occurred:

  • azurerm_log_analytics_solution.aks_s: 1 error(s) occurred:

  • azurerm_log_analytics_solution.aks_s: Error retrieving Log Analytics Solution “Containers(acctest-01)” (Resource Group “acctestRG-01”): operationsmanagement.SolutionsClient#Get: Failure responding to request: StatusCode=404 – Original Error: autorest/azure: error response cannot be parsed: “Solution Not Found : solutionType Containers, workspace acctest-01” error: invalid character ‘S’ looking for beginning of value

Terraform does not automatically rollback in the face of errors. Instead, your Terraform state file has been partially updated with any resources that successfully completed. Please address the error above and apply again to incrementally change your infrastructure.

Expected Behavior

Solution should be assigned to existing log-analytics account

Actual Behavior

Solution deployment fails

Steps to Reproduce

run provided configuration

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 22
  • Comments: 15 (6 by maintainers)

Most upvoted comments

What solved the issue for me was setting solution_name to match the plan.product, which in my case was just ContainerInsights. I figured out the solution by enabling the debug log and inspecting raw API responses, so better error messages would be nice, indeed

In our case the character is ‘F’:

Error: Error creating/updating Log Analytics Solution (Workspace "/subscriptions/xxxxxxxxx/resourcegroups/xxxxx/providers/microsoft.operationalinsights/workspaces/security-xxxxxxx" / Resource Group "c7n-aks"): pollingTrackerBase#updateRawBody: failed to unmarshal response body: StatusCode=0 -- Original Error: invalid character 'F' looking for beginning of value

what worked for us is just using:

solution_name = "ContainerInsights

Changing the name to "ContainerInsights` worked for us as well. Debugging terraform you can see that with other names you get a 400 bad request error for the underlying API The reason for this seems to be the name passed to the API adds the name of workspace to it like so - test1233ContainerInsights(test1233-workspace-**********)

Seems like an issue with the API and a good error message will really help.

API in question is - https://management.azure.com/subscriptions/*****/resourcegroups/******/providers/Microsoft.OperationsManagement/solutions/*******?api-version=2015-11-01-preview

Terraform v0.11.11
+ provider.azurerm v1.21.0

Ours is a different error character “W” and is Error creating/updating instead of Error retrieving

* azurerm_log_analytics_solution.akslaw: 1 error(s) occurred:

* azurerm_log_analytics_solution.akslaw: Error creating/updating Log Analytics Solution 
"ContainerInsights(prduse-xxx-law)" 
(Workspace "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-0eb53147bb93/resourcegroups/prduse-xxx-la-rg/providers/microsoft.operationalinsights/workspaces/prduse-xxx-law" 
/ Resource Group "prduse2xxxxxrg"): pollingTrackerBase#updateRawBody: 
failed to unmarshal response body: 
StatusCode=0 -- Original Error: invalid character 'W' looking for beginning of value

I tried again with the resource group matching the workspace resource group and it succeeded. Perhaps we could use some better error messages? Or we are not parsing them correctly…