Created
May 4, 2014 20:06
-
-
Save ytechie/8d718f597948f1761044 to your computer and use it in GitHub Desktop.
Quick and dirty table storage delete all rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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