Skip to content

Instantly share code, notes, and snippets.

@ytechie
Created May 4, 2014 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytechie/8d718f597948f1761044 to your computer and use it in GitHub Desktop.
Save ytechie/8d718f597948f1761044 to your computer and use it in GitHub Desktop.
Quick and dirty table storage delete all rows
class Program
{
static void Main(string[] args)
{
var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=ACCOUNT_NAME;AccountKey=ACCOUNT_KEY");
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("elmaherrors");
// var query = new TableQuery();
var projectionQuery = new TableQuery<DynamicTableEntity>().Select(new string[] { "PartitionKey" });
while (true)
{
var entities = table.ExecuteQuerySegmented(projectionQuery, new TableContinuationToken()).ToList();
if (entities.Count == 0)
Environment.Exit(0);
foreach (var entity in entities)
{
var delete = TableOperation.Delete(entity);
table.BeginExecute(delete, ar => { }, null);
}
Console.WriteLine("Deleted {0} entities", entities.Count);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment