void DoTestAllDataWithDictionaryMultiple() { bool isSuccess; try { StashClientOptions options = StashConfiguration.GetDefaultOptions(); AllDataWithDictionaryMultiple(options); // use large data must fail // if control came here we failed isSuccess = false; } catch (Exception) { isSuccess = true; } if (!isSuccess) { Assert.Fail(); } { StashClientOptions options = StashConfiguration.GetDefaultOptions(); options.SupportLargeObjectsInPool = true; AllDataWithDictionary entity = AllDataWithDictionaryMultiple(options); // now read without the support large pool options and validate the the entities do NOT match // and the unmapped pool count is different options.SupportLargeObjectsInPool = false; StashClient <AllDataWithDictionary> client = StashConfiguration.GetClient <AllDataWithDictionary>(options); AllDataWithDictionary entityRead = client.Get(entity.PartitionKey, entity.RowKey); Assert.IsFalse(entityRead.Equals(entity)); // now read without the support large pool options and validate the the entities DO match // and the unmapped pool count is different options.SupportLargeObjectsInPool = true; client = StashConfiguration.GetClient <AllDataWithDictionary>(options); entityRead = client.Get(entity.PartitionKey, entity.RowKey); Assert.IsTrue(entityRead.Equals(entity)); // delete client.Delete(entityRead); } }
GetStasherUsingCloudStorageAccount <T>( string settings, StashClientOptions options) { return(GetStasherUsingCloudStorageAccount <T>( GetCloudStorageAccount(settings), options)); }
GetStasherUsingCloudStorageAccount <T>( CloudStorageAccount account, StashClientOptions options) { options.UseHttps = account.TableEndpoint.Scheme == "https"; return(new StashClient <T>( account.Credentials.AccountName, new SignRequest(h => account.Credentials.SignRequestLite(h)), options)); }
GetClient <T>( StashClientOptions options) { // Change the type here to target different storage accounts and different credential methods. ConfigurationType configType = ConfigurationType.StashEmulator; StashClient <T> result = null; switch (configType) { // Use the StashCredential class. case ConfigurationType.StashCloud: result = new StashClient <T>( new StorageAccountKey( ConfigurationManager.AppSettings["AccountName"], ConfigurationManager.AppSettings["key"]), options); break; // The storage emulator credentials are built into Stash. case ConfigurationType.StashEmulator: result = new StashClient <T>( options); break; #if USE_STORAGE_CLIENT // Use the Azure Storage Client credentials infrastructure. case ConfigurationType.StorageAccountCloud: result = GetStasherUsingCloudStorageAccount <T>( "DataConnectionString", options); break; // Use the Azure Storage Client credentials infrastructure for the emulator. case ConfigurationType.StorageAccountEmulator: result = GetStasherUsingCloudStorageAccount <T>( "DataConnectionStringEmulator", options); break; #endif default: throw new ApplicationException("Incorrect Configuration Type."); } return(result); }
GetStasherUsingCloudStorageAccount <T>( CloudStorageAccount account, StashClientOptions options) { // indicate it https is selected. options.UseHttps = account.TableEndpoint.Scheme == "https"; // instantiate the client with the SignRequestLite method from the Credentials. return(new StashClient <T>( account.Credentials.AccountName, new SignRequest(h => account.Credentials.SignRequestLite(h)), options)); }
AllDataWithDictionaryMultiple( StashClientOptions options) { StashClient <AllDataWithDictionary> client = StashConfiguration.GetClient <AllDataWithDictionary>(options); AllDataWithDictionary entity = TypeFactory <AllDataWithDictionary> .Create(DataSize.Multiple); // DataSize.Multiple client.Insert(entity); AllDataWithDictionary entityRead = client.Get(entity.PartitionKey, entity.RowKey); Assert.IsTrue(entityRead.Equals(entity)); return(entityRead); }
GetClient <T>( StashClientOptions options) { StashClient <T> result = null; switch (ConfigType) { case ConfigurationType.StashCloud: result = new StashClient <T>( new StorageAccountKey( ConfigurationManager.AppSettings["AccountName"], ConfigurationManager.AppSettings["key"]), options); break; case ConfigurationType.StashEmulator: result = new StashClient <T>( options); break; #if USE_STORAGE_CLIENT case ConfigurationType.StorageAccountCloud: result = GetStasherUsingCloudStorageAccount <T>( "DataConnectionString", options); break; case ConfigurationType.StorageAccountEmulator: result = GetStasherUsingCloudStorageAccount <T>( "DataConnectionStringEmulator", options); break; #endif } return(result); }
AddRetryInterceptor( StashClientOptions options) { // Get a function which creates the policy and invoke it to get the actual policy var exponentatial = RetryPolicies.GetExponential( Retryable.DefaultAttempts, Retryable.DefaultDeltaBackoff)(); // create an interceptor which wraps the policy and assigns it to the option. options.RetryPolicy = () => (attempt, ex) => { System.Diagnostics.Debug.WriteLine( "Attempt = {0}. Exception = {1}", attempt, ex); return(exponentatial(attempt, ex)); }; }