public DynamicTableContext(string tableName, Credentials credentials) { if (tableName == null) throw new ArgumentNullException("tableName"); if (credentials == null) throw new ArgumentNullException("credentials"); this.credentials = credentials; this.tableName = tableName; }
public void Test04() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); dynamic item = new { PartitionKey = "1", RowKey = Guid.NewGuid().ToString(), Value = "Hello World" }; context.InsertOrReplace(item); }
public void Test02() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); dynamic item = context.Get("1", "1"); Assert.IsNotNull(item); Assert.AreEqual("1", item.PartitionKey); Assert.AreEqual("1", item.RowKey); }
public void Test05() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); dynamic item = new ExpandoObject(); item.PartitionKey = "1"; item.RowKey = Guid.NewGuid().ToString(); item.Value = "Hello World"; context.Insert(item); }
public void Test01() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); foreach (IDictionary<string, object> item in context.Query("Value1 eq 'TEST'")) { foreach (string key in item.Keys) { Console.WriteLine(key + " = " + item[key]); } } }
/// <summary> /// Signs the request for Shared Key Lite authentication. /// </summary> /// <param name="request">The web request.</param> /// <param name="credentials">The account credentials.</param> public static void SignRequestForSharedKeyLite(HttpWebRequest request, Credentials credentials) { Request.SignRequestForBlobAndQueuesSharedKeyLite(request, credentials); }
public void Test09() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); dynamic item = context.Get("1", "999"); // item does not exist Assert.IsNull(item); }
public void Test08() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); dynamic item = new { PartitionKey = "1", RowKey = "1", Value = "Hello World" }; context.Insert(item); }
public void Test07() { Credentials credentials = new Credentials(ACCOUNT_NAME, KEY); DynamicTableContext context = new DynamicTableContext(TABLE_NAME, credentials); var dictionary = new Dictionary<string, object>(); dictionary["PartitionKey"] = "2"; dictionary["RowKey"] = "2"; dictionary["Value3"] = "FooBar"; context.InsertOrReplace(dictionary); }
/// <summary> /// Signs requests using the SharedKeyLite authentication scheme with is used for the table storage service. /// </summary> /// <param name="request"> The request. </param> /// <param name="credentials"> The credentials. </param> internal static void SignRequestForTablesSharedKeyLite(HttpWebRequest request, Credentials credentials) { // Add the date header to the request var dateString = ConvertDateTimeToHttpString(DateTime.UtcNow); request.Headers.Add("x-ms-date", dateString); // Compute the signature and add the authentication scheme var canonicalizer = CanonicalizationStrategyFactory.GetTableLiteCanonicalizationStrategy(request); var message = canonicalizer.CanonicalizeHttpRequest(request, credentials.AccountName); var computedBase64Signature = StorageKey.ComputeMacSha256(credentials.Key, message); request.Headers.Add( "Authorization", string.Format( CultureInfo.InvariantCulture, "{0} {1}:{2}", "SharedKeyLite", credentials.AccountName, computedBase64Signature)); }
/// <summary> /// Signs the request for Shared Key authentication. /// </summary> /// <param name="request">The web request.</param> /// <param name="credentials">The account credentials.</param> /// <remarks>The table service usually expects requests to use Shared Key Lite authentication. /// Use <see cref="SignRequestForSharedKeyLite"/> for those requests.</remarks> public static void SignRequest(HttpWebRequest request, Credentials credentials) { Request.SignRequestForTablesSharedKey(request, credentials); }