从 Azure 存储 WADSLogTable 和 WADWindowsEventLogsTable 中删除记录

Deleting records from Azure Storage WADSLogTable and WADWindowsEventLogsTable

希望以编程方式在 .NET 中执行问题状态。我应该研究哪些图书馆?非常感谢指向代码示例的链接。

谢谢。

您可以参考下面的简单示例,它根据时间戳截断table,然后扫描table以获取数据。

    public void TruncateDiagnostics(CloudStorageAccount storageAccount, DateTime keepThreshold)
    {
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            CloudTable cloudTable = tableClient.GetTableReference("WADLogsTable");

            TableQuery query = new TableQuery();
            query.FilterString = string.Format("Timestamp lt datetime'{0:yyyy-MM-ddTHH:mm:ss}'", keepThreshold);
            var items = cloudTable.ExecuteQuery(query).ToList();

            Dictionary<string, TableBatchOperation> batches = new Dictionary<string, TableBatchOperation>();
            foreach (var entity in items)
            {
                TableOperation tableOperation = TableOperation.Delete(entity);

                if (!batches.ContainsKey(entity.PartitionKey))
                {
                    batches.Add(entity.PartitionKey, new TableBatchOperation());
                }

                batches[entity.PartitionKey].Add(tableOperation);
            }

            foreach (var batch in batches.Values)
            {
                cloudTable.ExecuteBatch(batch);
            }
    }

您可以从此线程中获取更多示例 Windows Azure - Cleaning Up The WADLogsTable.