Application Insights & Azure Table Storage CreateIfNotExists Errors

Thomas Pentenrieder
medialesson
Published in
1 min readMar 27, 2022
Photo by Tobias Fischer on Unsplash

When working with Azure Table Storage and Application Insights you might have noticed a lot of dependency errors, logging a 409 Conflict event everytime the CreateIfNotExists() method is called to make sure a table is available.

This is because the Azure.Data.Tables SDK will simply try to create a new table — and will hide the error if it already exists. While you don’t notice this in the code, by default Application Insights will catch this and clutter your logs with errors you probably don’t want.

To avoid this you can either configure the type of events Application Insights catches, or you can manually check if a table exists before trying to create it. Since this seamed a bit easier I’ve opted for option #2:

Note: I’m using the ToListAsync() method from the System.Linq.Async NuGet package to get all results from my queries without having to handle paging myself.

To make this even easier to use I published a NuGet package with this and more helpul extensions to the Azure.Data.Tables SKD. With that you can simply call

Originally published at https://medienstudio.net on March 27, 2022.

--

--