3

I have started using Azure.Storage.Blobs nuget in my Function Apps. Only problem it causes at the moment is that it logs a lot of unnecessary stuff that I don't need to see. Mainly Request and Response messages that fill a large amount of my application insights now.

Is there a way to remove those without touching any other logs? I would assume you should be able to do something from host.json, but so far nothing has worked for me to tackle this problem.

Example logs that I get:

Request [f42fdb4b-8d26-418d-ae67-1d4e79bdabd6] GET <resource_address> x-ms-version:2021-08-06 Accept:application/xml x-ms-client-request-id: x-ms-return-client-request-id:true User-Agent:azsdk-net-Storage.Blobs/12.13.0,(.NET 6.0.8; Microsoft Windows 10.0.14393) x-ms-date:Thu, 29 Sep 2022 19:07:43 GMT Authorization:REDACTED client assembly: Azure.Storage.Blobs

Response [f42fdb4b-8d26-418d-ae67-1d4e79bdabd6] 200 OK (00.0s) Accept-Ranges:bytes ETag:"" Server:Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0 x-ms-request-id: x-ms-client-request-id:<request_id> x-ms-version:2021-08-06 x-ms-version-id:REDACTED x-ms-is-current-version:REDACTED x-ms-creation-time:Thu, 29 Sep 2022 19:07:39 GMT x-ms-lease-status:unlocked x-ms-lease-state:available x-ms-blob-type:BlockBlob x-ms-server-encrypted:true Date:Thu, 29 Sep 2022 19:07:43 GMT Content-Length:222058 Content-Type:application/pdf Content-MD5: Last-Modified:Thu, 29 Sep 2022 19:07:39 GMT Content-Disposition:

In functions where blobs are handled there will be A LOT of request/response logs like these. I tend to wrap my operations with try-catch and log possible errors, so these are completely pointless to write.

BladeZ
  • 75
  • 5
  • Based on the question we have understood that you are trying to reduce the number of logs from function host to application insights, if my understanding is correct I would suggest you to make use of [sampling in application insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/sampling) for this.If you want to reduce the number of logs at function invocation.Could you help us with the sample logs to remove similar to this [github discussion](https://github.com/Azure/azure-functions-core-tools/issues/1440). – RKM Sep 30 '22 at 10:21
  • Hi @RajkumarM ! I added blob log examples to the original post. I have already read that github discussion you posted and tried similar tactics people suggested there. None of those helped unfortunately to solve this problem. – BladeZ Oct 02 '22 at 02:27

1 Answers1

0

I had the same problem when I used QueueTrigger, and my fix is to remove my TelemetryClient from singleton and in dependency injection. It also manages to remove all built-in logs. Example of the code.

public class Function1
{
        private readonly TelemetryClient _telemetryClient;

        public Function1() 
        {
            _telemetryClient = TelemetryClientHelper.GetInstance();
        }
}

public static class TelemetryClientHelper
    {
        private static TelemetryClient _telemetryClient;
        public static TelemetryClient GetInstance()
        {
            if(_telemetryClient == null)
            {
                var telemetryConfiguration = TelemetryConfiguration.CreateDefault();
                telemetryConfiguration.ConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING");
                _telemetryClient = new TelemetryClient(telemetryConfiguration);
            }
            
            return _telemetryClient;
        }
    }