How to Delete an Entire Azure Table in One Command
Here's how to delete an entire Azure table:
I get this question quite often. I normally wouldn't make such a simple post, but:
- Most developers think they need to delete rows one row at a time.
- And that isn't true.
There is, in fact, support for deleting a whole table.
- Here's the REST-based approach: http://msdn.microsoft.com/en-us/library/windowsazure/dd179387.aspx
- Here's the approach using the .NET libraries: http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services/#delete-table
// Retrieve storage account from connection string CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the table client CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Delete the table it if exists tableClient.DeleteTableIfExist("people");
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)