问题
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