Limiting unnecerry app insights .NET dependecy logs as dicussed in the post "Reducing Log Analytics Cost for App Insights by Removing Successful Dependency Logs Ingestion from .NET Applications" is useful to reduce the costs. However, there are some .NET SDK methods, which are generating unnecessary execptions when used, filling up app indsights with exceptions. Once such method usage is BlobContainerClient.CreateIfNotExists, where it will always throw a 409 conflict, if the blob container is already exist.
This is an unnecessary exception and we can simple avoid it by using BlobContainerClient.ExistsAsync before we use BlobContainerClient.CreateAsync to create te blob container, instead of using SDK provided method BlobContainerClient.CreateIfNotExists, as shown below.
protected static async Task CreateBlobContainerIfNotExistAsync(BlobContainerClient container) { if (!await container.ExistsAsync()) { await container.CreateAsync(); } }
No comments:
Post a Comment