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

azurerm_monitor_diagnostic_setting is having problem in read and creation. #26545

Open
1 task done
findajay opened this issue Jul 5, 2024 · 1 comment
Open
1 task done

Comments

@findajay
Copy link

findajay commented Jul 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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 comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.

Terraform Version

1.3.7

AzureRM Provider Version

3.75.0

Affected Resource(s)/Data Source(s)

azurerm_monitor_diagnostic_setting

Terraform Configuration Files

# resource "azurerm_monitor_diagnostic_setting" "function_diagnostic_log" {
#   for_each           = data.azurerm_linux_function_app.function_apps
#   name               = "${each.key}-diagnostic-logs"
#   target_resource_id = data.azurerm_linux_function_app.function_apps[each.key].id
#   storage_account_id = data.azurerm_storage_account.function_storageaccount[each.key].id

#   enabled_log {
#     category = "FunctionAppLogs"
#   }
# }

Debug Output/Panic Output

╷
│ Error: checking for presence of existing Monitor Diagnostic Setting "worker-diagnostic-logs" for Resource "/subscriptions/5f7f3495-660d-40b7-8bc1-6f36a22c7565/resourceGroups/nucleus-dev-contracts/providers/Microsoft.Web/sites/vs-nucleus-dev-contracts-worker": diagnosticsettings.DiagnosticSettingsClient#Get: Failure responding to request: StatusCode=500 -- Original Error: autorest/azure: Service returned an error. Status=500 Code="Unknown" Message="Unknown service error" Details=[{"code":"InternalServerError","message":""}]
│ 
│   with module.service.azurerm_monitor_diagnostic_setting.function_diagnostic_log["worker"],
│   on .terraform/modules/service/terraform/modules/services/web_api/function_app.tf line 320, in resource "azurerm_monitor_diagnostic_setting" "function_diagnostic_log":
│  320: resource "azurerm_monitor_diagnostic_setting" "function_diagnostic_log" {
│ 
╵
##[error]Script failed with error: Error: The process '/usr/bin/bash' failed with exit code 1
    at ExecState._setResult (/agent/_work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/1.238.4/node_modules/azure-pipelines-task-lib/toolrunner.js:1219:25)
    at ExecState.CheckComplete (/agent/_work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/1.238.4/node_modules/azure-pipelines-task-lib/toolrunner.js:1202:18)
    at ChildProcess.<anonymous> (/agent/_work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/1.238.4/node_modules/azure-pipelines-task-lib/toolrunner.js:1115:19)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)

Expected Behaviour

Existing Diagnotic settings must be read during plan or new must be created

Actual Behaviour

terraform fails in both step in reading the resource in plan and create in apply step

Steps to Reproduce

Create an azure function and try to enable diagnostic setting on azure function using azurerm_monitor_diagnostic_setting

Important Factoids

No response

References

No response

@teowa
Copy link
Contributor

teowa commented Jul 5, 2024

Hi @findajay ,
The Status=500 Code="Unknown" Message="Unknown service error" Details=[{"code":"InternalServerError","message":""}] error message should be backend issue which means the API has some error. I am unable to reproduce it with below config. Could you please reproduce it with the latest provider 3.111.0 version and provide the config which can be reproduced? thanks.

terraform config
provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-funcapp-resources"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "linuxfunctionappsawtte"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_service_plan" "example" {
  name                = "example-app-service-plan"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  os_type             = "Linux"
  sku_name            = "Y1"
}

resource "azurerm_linux_function_app" "example" {
  name                = "example-linux-function-appwttest"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  storage_account_name       = azurerm_storage_account.example.name
  storage_account_access_key = azurerm_storage_account.example.primary_access_key
  service_plan_id            = azurerm_service_plan.example.id

  site_config {}
}

resource "azurerm_monitor_diagnostic_setting" "example" {
  name               = "example"
  target_resource_id = azurerm_linux_function_app.example.id
  storage_account_id = azurerm_storage_account.example.id

  enabled_log {
    category = "FunctionAppLogs"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants