How to delete an entire Azure Table in one command

 

How to delete an entire Azure Table in one command

Rate This
  • Comments 2

Deleting an Entire Azure Table
001
  1. How to delete an entire Azure table is quite easy.
  2. I get this question quite often. I normally would not create such a simple post.
    1. Most developers think they need to delete rows, one row at a time.
    2. But that isn't true.
  3. There is support for deleting a whole table.
  4. Here is the REST-based approach
  5. Here is the approach using the .NET libraries

Sample.cs
  Sample.cs
1
2
3
4
5
6
7
8
9
10
// 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");


Cheers,
Hope this helps.
  • One thing I would like to point out is that this operation will actually start deletion operation. Windows Azure Storage service would mark this table as "To Be Deleted" (or something like it) so that any attempt to access this table (like read/write etc.) will throw an error. However the actual deletion process could take a lot of time depending on the number of entities you have in that table. While the table "is being deleted" any attempt to recreate the table will result in an error.

  • actually I have a azure table with about 1~2 million records.

    I've tried several times to delete the table but got 500 error.

    I don't know whether there is any other better idea to delete one azure table.

     

    [send me your code at bterkaly@microsoft.com]

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post