I have a function that needs to upload a text/stream blob to a container in Azure Blob Storage. The code looks like this:
public async Task<bool> UploadBlobAsync(CloudBlobContainer container,string fileName, string content)
{
BlobRequestOptions options = new BlobRequestOptions
{
RetryPolicy = LinearRetry(TimeSpan.FromSeconds(20),3),
ServerTimeout = TimeSpan.FromSeconds(90)
};
await container.CreateIfNotExistsAsync();
CloudBlockBlob blob = container.GetBlockBlobReference(fileName);
await blob.DeleteIfExistsAsync();
await blob.UploadTextAsync(content,null,options,null);
}
}
The code works fine, but I get dependency exceptions showing up on Azure AppInsights (409 PUT Exception and 404 Delete Exception). I'm not sure which line causes this dependency exception to show up.
Does anyone know why this happens, or if there is any way to prevent these dependency exceptions from being logged on Azure AppInsights?
Does anyone know why this happens, or if there is any way to prevent these dependency exceptions from being logged on Azure AppInsights?
Dependency exception of 409
is coming from await container.CreateIfNotExistsAsync();
. This method tries to create a blob container and if the blob container exists, Blob Storage service returns a Conflict (409)
exception back which this method swallows. However, App Insights dependency tracking still logs this exception.
Dependency exception of 404
is coming from await blob.DeleteIfExistsAsync();
. This method tries to delete a blob and if the blob does not exist, Blob Storage service returns a Not Found (404)
exception back which this method swallows. However, App Insights dependency tracking still logs this exception.
AFAIK, there is no way to prevent these dependency exceptions from being logged on Azure AppInsights except you turning off dependency tracking completely. You can turn off dependency tracking by setting EnableDependencyTrackingTelemetryModule
to false
in your app settings.
Something like:
"ApplicationInsights": {
....other settings,
"EnableDependencyTrackingTelemetryModule": false,
"ConnectionString": "connection-string"
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.