/// <summary> /// It tries to read the <see cref="StorageAccountConnectionString" />. /// If not found, it creates a new storage account on Azure. /// </summary> /// /// <returns>The active Azure storage account for this test run.</returns> /// private StorageProperties EnsureStorageAccount() { if (!string.IsNullOrEmpty(StorageAccountConnectionString)) { var connectionString = StorageAccountConnectionString; var nameStart = (connectionString.IndexOf('=', connectionString.IndexOf("AccountName")) + 1); var nameLength = (connectionString.IndexOf(';', nameStart) - nameStart); return(new StorageProperties(connectionString.Substring(nameStart, nameLength), connectionString, shouldRemoveAtCompletion: false)); } return(Task .Run(async() => await StorageScope.CreateStorageAccountAsync().ConfigureAwait(false)) .ConfigureAwait(false) .GetAwaiter() .GetResult()); }
/// <summary> /// Requests creation of an Azure storage account to use for a specific test run, /// transforming the asynchronous request into a synchronous one that can be used with /// lazy instantiation. /// </summary> /// /// <returns>The active Azure storage account for this test run.</returns> /// private static StorageScope.StorageProperties CreateStorageAccount() => Task .Run(async() => await StorageScope.CreateStorageAccountAsync().ConfigureAwait(false)) .ConfigureAwait(false) .GetAwaiter() .GetResult();