private BlobRdDataStorage CreateAzureBlobRdDataStorage(out Mock <IRdDataStorage> metadataStorage) { metadataStorage = new Mock <IRdDataStorage>(); metadataStorage .Setup(x => x.StoreAsync(It.IsAny <string>(), It.IsAny <GenericDataContainer>(), It.IsAny <bool>())) .Returns <string, GenericDataContainer, bool>((dataType, container, overwrite) => Task.FromResult(new StoreResult(container.Id, DataModificationType.Created, false))); var cloudAccount = new CloudStorageAccount( new StorageCredentials("dataapiblob", Secrets.Get("DataAPI_BlobStorageKey")), true); var azureBlobStorage = new AzureBinaryDataStorage(cloudAccount); return(new BlobRdDataStorage(DataStorageTypes.AzureBlobStorage, azureBlobStorage, metadataStorage.Object, new DummyIdGeneratorManager())); }
private void SetupAzureBlobStorages( List <IRdDataStorage> rdDataStorages, IdGeneratorManager idGeneratorManager, IConfiguration configuration) { var azureBlobStorageAccountName = configuration["AzureBlobStorage:User"]; if (!string.IsNullOrWhiteSpace(azureBlobStorageAccountName)) { var accessKey = Secrets.Get(configuration["AzureBlobStorage:AccessKeyEnvironmentVariable"]); var azureCloudAccount = new CloudStorageAccount( new StorageCredentials(azureBlobStorageAccountName, accessKey), useHttps: true); var azureBlobStorage = new AzureBinaryDataStorage(azureCloudAccount); var rdAzureBlobStorage = new BlobRdDataStorage( DataStorageTypes.AzureBlobStorage, azureBlobStorage, rdDataStorages.Single(x => x.Id == DataStorageTypes.MongoDB), idGeneratorManager); rdDataStorages.Add(rdAzureBlobStorage); } }