DEV Community

Frits Becker
Frits Becker

Posted on • Edited on

Azure functions throw errors when diagnostic settings are enabled for the storage account.

Issue is fixed!!!

The issue from this blog is fixed with v4.839.500, v4.639.500 and v4.1039.500. Check your logs for the host SDK and when it is updated, we should be able to remove whatever workaround is chosen.

Introduction

Recently, we added a mandatory diagnostic setting to the blob service in our storage account module. This sends audit logs to a central log analytics workspace.

resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
  scope: blobService
  name: 'auditlogs'
  properties: {
    logs: [
      {
        enabled: true
        categoryGroup: 'audit'
      }
    ]
    workspaceId: auditWorkspace.id
  }
}
Enter fullscreen mode Exit fullscreen mode

When Issues Arise

When updating the storage account module in the infra repository of a DevOps team, errors began to appear in their application insights. Errors like:

  • Error occurred when attempting to purge previous diagnostic event versions.
  • Unable to get table reference or create table. Aborting write operation.

All of them had Category "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.DiagnosticEventTableStorageRepository"

Quest for answers

We had no idea why this happened, so we began our quest and quickly found multiple issues on the "Azure Functions Host" GitHub repository.

Luckily this bug was fixed in october last year with the PR 'Added support for identity-based connections to Diagnostic Events' and released on December 19th in version 4.837.0.

We used a managed identity to assign the correct roles to the functions on the storage account. Upon checking the error logs, we discovered that we were using SDK version 4.1038.300.25164. But the problem was that downgrading is not possible. we tried to change FUNCTIONS_EXTENSION_VERSION, but it does not work as expected. So we had to find out why this error is back and how to fix this.

We found out that MSFT updated to version 4.1038.300.25164 on 4/16/2025. Before that, the logs show version 4.1037.1.23605, where there were no problems. For now, we have to wait for a fix, but we can find 2 issues in the Azure Function Host GitHub with some temporary changes to avoid/ignore the errors.

Temporary solutions

Here are some options that are given in the issues:

  • For the time being, you can add a log filter for Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.DiagnosticEventTableStorageRepository to host.json and filter out logs.
  • You can also disable this feature via an app setting: AzureWebJobsFeatureFlags=DisableDiagnosticEventLogging.

The PR we are waiting for to be released right now is PR 10996.

Top comments (4)

Collapse
 
faraz_ahmad_07077cb55d65e profile image
Faraz Ahmad • Edited

why you have downgraded your version from 4.1038 to 4.837.x ? Does the latest version does not contains the fixes from 4.837?

How to do we enforce this version in azure? Can you tell where to make that change? I have updated the Microsoft.Azure.Functions.Worker package and in app insight i can see the SDK as 4.1038.400.3

Collapse
 
frits-becker profile image
Frits Becker

Hello Faraz,

Thank you for your reply. I initially thought we had downgraded the version with FUNCTIONS_EXTENSION_VERSION, but unfortunately, it did not work as expected. My sincere apologies for the incorrect information.

I have done more research and updated the blog. I hope this helps you for now. 😊

Collapse
 
faraz_ahmad_07077cb55d65e profile image
Faraz Ahmad

That was helpful Frits :)
Adding this resolved my issue
AzureWebJobsFeatureFlags=DisableDiagnosticEventLogging

Thread Thread
 
frits-becker profile image
Frits Becker

Hello Faraz,

I just added the final update for this blog. The issue is fixed and you will see the version number on the top of this blog :).