hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.51k stars 4.6k forks source link

azurerm_windows_web_app log settings constant re-apply #16876

Open RackPhilO opened 2 years ago

RackPhilO commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.1.7

AzureRM Provider Version

3.6.0

Affected Resource(s)/Data Source(s)

azurerm_windows_web_app

Terraform Configuration Files

resource "azurerm_windows_web_app" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_service_plan.example.location
  service_plan_id     = azurerm_service_plan.example.id

  site_config {}
  logs {
    detailed_error_messages = true
    failed_request_tracing  = true
    application_logs {
      file_system_level = "Information"
      azure_blob_storage {
        level             = "Information"
        sas_url           = "${azurerm_storage_container.api-ui-log.id}${data.azurerm_storage_account_blob_container_sas.api-ui-log.sas}"
        retention_in_days = var.log_rention_policy_days
      }
    }
    http_logs {
      azure_blob_storage {
        sas_url           = "${azurerm_storage_container.api-ui-log.id}${data.azurerm_storage_account_blob_container_sas.api-ui-log.sas}"
        retention_in_days = var.log_rention_policy_days
      }
    }
  }
}

Debug Output/Panic Output

~ logs {
            # (2 unchanged attributes hidden)

          + application_logs {
              + file_system_level = "Information"

              + azure_blob_storage {
                  + level             = "Information"
                  + retention_in_days = 90
                  + sas_url           = (sensitive)
                }
            }

Expected Behaviour

The app service logs will by default turn themselves off after 12 hours . If you have defined a block of code including them there is no option to set the level to Off as per the resource ..

image

The schema does not have an option for 'Off' >>

func applicationLogSchema() pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, Optional: true, MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]pluginsdk.Schema{ "file_system_level": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ string(web.LogLevelError), string(web.LogLevelInformation), string(web.LogLevelVerbose), string(web.LogLevelWarning), }, false), },

"azure_blob_storage": appLogBlobStorageSchema(), }, }, } }

The deprecated app_service resource did

App Service = file_system_level - (Optional) Log level for filesystem based logging. Supported values are Error, Information, Verbose, Warning and Off. Defaults to Off.

Web App = file_system_level - (Required) Log level. Possible values include: Verbose, Information, Warning, and Error.

Actual Behaviour

Service default to Off after 12 hours so any subsequent re-apply via code will trigger a change . Would like to be able to set the code to off and allow the blob storage section to be applied without 'flip flopping' in the code

Steps to Reproduce

No response

Important Factoids

No response

References

No response

xiaxyi commented 2 years ago

checking the detailed practice both from windows app and Linux app, will update the code accordingly.

ptpu commented 1 year ago

Hey, any updates on that? We would like to deactivate the file_system_level too and just use azure_blob_storage

validis-ad commented 10 months ago

I'm not sure why the bug label was removed as it strikes me as quite obviously a bug. Terraform is conflicting with the expectations of the platform. I suppose it could come down to semantics, but on the face of it the module is the "bad actor" here, breaking any sense of idempotence.

ValeruS commented 7 months ago

Any updates ?