Beispiel #1
0
        public void Run()
        {
            string connectionString = "DefaultEndpointsProtocol=http;AccountName=portalvhds87hz1yygyk79j;AccountKey=6len1IQCc77uMq96IH4XnEqHuytM/2OKbEWyarABG+8J++r4XtcRY2BocozzkFKZvtTxakklGgoLPDSUYgSe2A==";
            //string connectionString = ConfigurationManager.ConnectionStrings["SillyTest.Properties.Settings.StorageConnectionString"].ConnectionString;
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();

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

            cloudTable.CreateIfNotExists();

            TableBatchOperation tableOperation = new TableBatchOperation();

            string resourceId = "6d561db9-2a5c-4729-ab98-f8f9b58598e7";

            for (int i = 0; i < 100; i++)
            {
                AuditItem auditItem = new AuditItem("ff554330-6901-4266-8410-f25d0f110792", resourceId, DateTime.UtcNow, "SELECT * FROM X");
                tableOperation.Insert(auditItem);
            }
            cloudTable.ExecuteBatch(tableOperation);

            TableQuery <AuditItem> query = new TableQuery <AuditItem>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "ff554330-6901-4266-8410-f25d0f110792_6d561db9-2a5c-4729-ab98-f8f9b58598e7"));

            foreach (AuditItem auditItem in cloudTable.ExecuteQuery(query))
            {
                Console.WriteLine("{0} {1}", auditItem.EventTime, auditItem.ETag);
            }
        }
Beispiel #2
0
 public void AuditLog(AuditItem auditItem)
 {
     WriteEvent(1, auditItem.Statement, auditItem.SubscriptionId, auditItem.ResourceId);
 }