Lee Englestone
Lee Englestone

Reputation: 4669

Is there any overhead of using CreateTableIfNotExists or DoesTableExist with Azure Table Storage?

Is there any overhead in using CreateTableIfNotExists() when using Azure Table Storage?

If so, what kind of overhead? I'm just wondering if it is worth always leaving in there or not?

Else should a check using DoesTableExist() be used instead each time? Which is preferable?

Upvotes: 1

Views: 309

Answers (1)

Peter Bons
Peter Bons

Reputation: 29711

Yes there is. For one, it adds an extra http call. Next, under the hood it performs a Create(). If it fails due to the fact a resource with that name already exists an http 409 error occurs. You will find the in the logs as well, for example in Application Insights. That error is caught and the value true is returned in that case.

Now, from another point of view. Say you have an application that is using a table to store data (well, what else would you do with it?). Now, one day someone makes a mistake and accidentally deletes the table. In your scenario this will go unnoticed for a while because the table is recreated without notice. So depending on the use case it might take a while before the error is discovered.

One option could be to check for existence on start up and log a warning if it does not exists or something like that.

Upvotes: 4

Related Questions