Azure Blob Storage successful requests show as failed requests in Application Insights

本小妞迷上赌 提交于 2021-02-08 07:59:24

问题


The following container exists and hence returns failed request code 409

var container = blobClient.GetContainerReference("my-container");
container.CreateIfNotExists();

I do a check to make sure the Blob reference doesn't exist before creating. This returns a 404 response code with a bool.

if(container.GetBlockBlobReference("this-file-could-exist").Exists()) {

In the first example I expect the container to exist, in the second expect the file not to exist. But in both cases I do a check to make sure.

The code all works fine. The issue is that Application Insights alerts me to a heap of failed requests. Although these are not really failed requests there actually successful request because thats what I expect.

Whats the best way to resolve this? Can I make azure return 200 success or do I need to ignore these in Application Insights somehow.


回答1:


If you are using the latest version of the Storage Client Library, when you execute CloudBlobContainer.CreateIfNotExists() method, it actually execute create operation, so sometimes server response will be 409.

Source code of version 8.2.0

If possible, you can try to downgrade your Storage Client Library version to v7.2.1.

Source code of version 7.2.1

I execute the following code in my About action, I can find the Result code in application insight is 200.

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

container.CreateIfNotExists();




回答2:


One possibility is to add a telemetry processor to your app that throws away things you don't ever want to see.

in this sample: https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling

// Example: replace with your own criteria.
private bool OKtoSend (ITelemetry item)
{
    var dependency = item as DependencyTelemetry;
    if (dependency == null) return true;

    return dependency.Success != true;
}

they have a telemetry processor that just flat out ignores any dependency calls that succeeded, only sending telemetry for failed dependencies.

you could write similar logic and just filter out dependencies that were 409's, or you could modify dependencies that were 409's and mark them as success instead of failures.



来源:https://stackoverflow.com/questions/45227439/azure-blob-storage-successful-requests-show-as-failed-requests-in-application-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!