public async Task TestBlobStorageChanges() { // Arrange var storageAccount = CloudStorageAccount.Parse(ConnectionString); var storage = new AzureBlobStorage(storageAccount, ContainerName); // Act await storage.WriteAsync(new Dictionary <string, object> { { "a", "1.0" }, { "b", "2.0" } }); await storage.WriteAsync(new Dictionary <string, object> { { "c", "3.0" } }); await storage.DeleteAsync(new[] { "b" }); await storage.WriteAsync(new Dictionary <string, object> { { "a", "1.1" } }); var result = await storage.ReadAsync(new[] { "a", "b", "c", "d", "e" }); // Assert Assert.AreEqual(2, result.Count); Assert.AreEqual("1.1", result["a"]); Assert.AreEqual("3.0", result["c"]); }
public async Task <FileStreamResult> Download(long documentId, string clientId, string secret, string userId) { //Validate clientId & secret if ((!Repository.AppManagement.IsValidUser(userId)) || (!Repository.AppManagement.IsValidClientSecret(clientId, secret))) { return(null); } Models.Document document = Repository.Documents.Get(documentId); AzureBlobStorage azure = new AzureBlobStorage(); using (MemoryStream memStream = new MemoryStream()) { MemoryStream output = await azure.DownloadSingleFileAsync(document); byte[] file = memStream.ToArray(); if (output != null) { output.Write(file, 0, file.Length); output.Position = 0; HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + document.Name); return(File(output, MIMEAssistant.GetMIMEType(document.Name))); } else { //What to do here? If Azure blob storage connection settings are not valid then this is where code will land return(null); } } }
static void Main(string[] args) { // Put your DI here var storage = new AzureBlobStorage(); // Read a local file using (FileStream file = File.Open(@"C:\cartoon.PNG", FileMode.Open)) { try { // Pattern to run an async code from a sync method storage.Create(file, "1.png").ContinueWith(t => { if (t.IsCompletedSuccessfully) { Console.Out.WriteLine("Blob uploaded"); } }).Wait(); } catch (Exception e) { // Omitted } } }
/// <summary> /// Get store from container identifier /// </summary> /// <param name="containerIdentifier">Container identifier</param> /// <returns>CB store</returns> public async Task <CBStore> GetStore(ContainerIdentifier containerIdentifier) { ContainerDescriptor containerDescriptor = ContainerDescriptorProvider.Containers[containerIdentifier]; string azureStorageConnectionString = await this.connectionStringProvider.GetBlobsAzureStorageConnectionString(containerDescriptor.AzureStorageInstanceType); string azureCdnUrl = await this.connectionStringProvider.GetAzureCdnUrl(containerDescriptor.AzureCdnInstanceType); string uniqueStoreIdentity = string.Join(":", azureStorageConnectionString, azureCdnUrl); // cachedStoreObjects is a thread-safe dictionary (ConcurrentDictionary). If uniqueStoreIdentity is not present // in cachedStoreObjects, try adding it. Since GetStore can be called concurrently by // different threads, it is possible for two (or more) threads to attempt inserting uniqueStoreIdentity // concurrently in the cachedStoreObjects. That's ok, because the call to TryAdd is guaranteed to be thread-safe. // One of the threads will not be able to insert (i.e., TryAdd will return false), but the code will happily execute // and fall through to the return statement. // This code makes no use of locking on the common path (i.e., reads of cachedStoreObjects). if (!cachedStoreObjects.ContainsKey(uniqueStoreIdentity)) { AzureBlobStorage azureBlobStorage = new AzureBlobStorage(azureStorageConnectionString); azureBlobStorage.BlobRequestOptions = AzureStorageConfiguration.GetBlobRequestOptions(); AzureCdn azureCdn = new AzureCdn(azureCdnUrl); CBStore store = new CBStore(azureBlobStorage, azureCdn); cachedStoreObjects.TryAdd(uniqueStoreIdentity, store); } return(cachedStoreObjects[uniqueStoreIdentity]); }
private static async Task StartWriterAsync(AzureBlobStorage azureBlobStorage, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) { try { await azureBlobStorage.WriteAsync( new Dictionary <string, object> { { StorageKeys[0], new Dictionary <string, object>() { { "Value1", 13177 }, { "Value2", Guid.NewGuid() }, { "Value3", new { SubValue = "Sub" } }, { "Value4", DateTime.UtcNow } } } }, cancellationToken); } catch (Exception exception) { Console.WriteLine("WRITER EXCEPTION: {0}", exception); } } }
public async Task TestConversationStateBlobStorage() { // Arrange var storageAccount = CloudStorageAccount.Parse(ConnectionString); var storage = new AzureBlobStorage(storageAccount, ContainerName); var conversationState = new ConversationState(storage); var propAccessor = conversationState.CreateProperty <Prop>("prop"); var adapter = new TestStorageAdapter(); var activity = new Activity { ChannelId = "123", Conversation = new ConversationAccount { Id = "abc" }, }; // Act var turnContext1 = new TurnContext(adapter, activity); var propValue1 = await propAccessor.GetAsync(turnContext1, () => new Prop()); propValue1.X = "hello"; propValue1.Y = "world"; await conversationState.SaveChangesAsync(turnContext1, force : true); var turnContext2 = new TurnContext(adapter, activity); var propValue2 = await propAccessor.GetAsync(turnContext2); // Assert Assert.AreEqual("hello", propValue2.X); Assert.AreEqual("world", propValue2.Y); }
public async Task TestBlobStorageWriteRead() { if (CheckEmulator()) { // Arrange var storageAccount = CloudStorageAccount.Parse(ConnectionString); var storage = new AzureBlobStorage(storageAccount, ContainerName); var changes = new Dictionary <string, object> { { "x", "hello" }, { "y", "world" }, }; // Act await storage.WriteAsync(changes); var result = await storage.ReadAsync(new[] { "x", "y" }); // Assert Assert.AreEqual(2, result.Count); Assert.AreEqual("hello", result["x"]); Assert.AreEqual("world", result["y"]); } }
protected override void Load(ContainerBuilder builder) { builder.RegisterType <CampaignsRepository>() .As <ICampaignsRepository>() .SingleInstance(); builder.RegisterType <VouchersRepository>() .As <IVouchersRepository>() .SingleInstance(); builder.RegisterType <CampaignContentsRepository>() .As <ICampaignContentsRepository>() .SingleInstance(); builder.RegisterType <PaymentRequestsRepository>() .As <IPaymentRequestsRepository>() .SingleInstance(); builder.RegisterMsSql( _connectionString, connString => new SmartVouchersContext(connString, false), dbConn => new SmartVouchersContext(dbConn)); builder.Register(c => new FileRepository(AzureBlobStorage.Create(_rulesImageConnString))) .As <IFileRepository>() .SingleInstance(); builder.Register(c => new FileInfoRepository( AzureTableStorage <FileInfoEntity> .Create(_rulesImageConnString, CampaignsTableName, c.Resolve <ILogFactory>()), c.Resolve <IMapper>())) .As <IFileInfoRepository>() .SingleInstance(); }
public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>(); services.AddSingleton <IBotServices, BotServices>(); services.AddSingleton <IStorage, MemoryStorage>(); services.AddSingleton <UserState>(); services.AddSingleton <ConversationState>(); services.AddSingleton <RootDialog>(); services.AddTransient <IBot, QnABot <RootDialog> >(); string storageAccount = Configuration.GetValue <string>("StorageAccount"); string storageContainerName = Configuration.GetValue <string>("StorageContainerName"); AzureBlobStorage storage = new AzureBlobStorage(storageAccount, storageContainerName); services.AddSingleton <IStorage>(storage); services.AddSingleton <ConversationState>(); services.AddSingleton <ConcurrentDictionary <string, ConversationReference> >(); services.AddBot <QnABot <RootDialog> >(options => { options.Middleware.Add(new ContextLogger()); }); services.AddSingleton <NotificationDialog>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var storage = new AzureBlobStorage( Configuration.GetSection("StorageConnectionString").Value, Configuration.GetSection("StorageContainer").Value ); var userState = new UserState(storage); services.AddSingleton(userState); var conversationSate = new ConversationState(storage); services.AddSingleton(conversationSate); services.AddControllers().AddNewtonsoftJson(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>(); services.AddSingleton <ILuisService, LuisService>(); services.AddSingleton <RootDialog>(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddTransient <IBot, ClinicBot <RootDialog> >(); }
protected override void Load(ContainerBuilder builder) { builder.Register(container => new MessageContentRepository(AzureBlobStorage.Create(_connectionString, TimeSpan.FromMinutes(15)))) .As <IMessageContentRepository>() .SingleInstance(); }
private async Task TestConversationStateBlobStorage_Method(AzureBlobStorage storage) { if (StorageEmulatorHelper.CheckEmulator()) { await ContainerInit(); // Arrange var conversationState = new ConversationState(storage); var propAccessor = conversationState.CreateProperty <Prop>("prop"); var adapter = new TestStorageAdapter(); var activity = new Activity { ChannelId = "123", Conversation = new ConversationAccount { Id = "abc" }, }; // Act var turnContext1 = new TurnContext(adapter, activity); var propValue1 = await propAccessor.GetAsync(turnContext1, () => new Prop()); propValue1.X = "hello"; propValue1.Y = "world"; await conversationState.SaveChangesAsync(turnContext1, force : true); var turnContext2 = new TurnContext(adapter, activity); var propValue2 = await propAccessor.GetAsync(turnContext2); // Assert Assert.AreEqual("hello", propValue2.X); Assert.AreEqual("world", propValue2.Y); } }
static async Task Main(string[] args) { var azureStorageConnectionString = default(string); var azureStorageContainerName = default(string); if (args.Length == 1) { azureStorageConnectionString = args[0]; } else { azureStorageConnectionString = Environment.GetEnvironmentVariable(AzureStorageConnectionStringEnvironmentVariableName); } if (azureStorageConnectionString == default(string) || azureStorageConnectionString.Length == 0) { Console.WriteLine($"ERROR: No valid connection string supplied. Pass as an arg or set \"{AzureStorageConnectionStringEnvironmentVariableName}\" environment variable."); return; } if (args.Length == 2) { azureStorageContainerName = args[1]; } if (azureStorageContainerName == null) { azureStorageContainerName = "testbotstorage"; } var azureBlobStorage = new AzureBlobStorage(azureStorageConnectionString, azureStorageContainerName); var cts = new CancellationTokenSource(); Console.WriteLine("Starting reader/writer..."); var readerTask = StartReaderAsync(azureBlobStorage, cts.Token); var writerTask = StartWriterAsync(azureBlobStorage, cts.Token); Console.WriteLine("Reader/writer now running..."); Console.WriteLine("Press any key to stop."); Console.ReadKey(true); cts.Cancel(); try { await Task.WhenAll(readerTask, writerTask); } catch (TaskCanceledException) { } Console.WriteLine("Done."); }
protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); builder.RegisterType <InputValidator>() .As <IInputValidator>() .SingleInstance() .WithParameter(TypedParameter.From(_settings.CurrentValue.MaxPayloadSizeBytes)); builder.Register(ctx => new ClientDictionaryBlob( AzureBlobStorage.Create( _settings.ConnectionString(x => x.Db.DataConnString)), new ClientKeysToBlobKeys( AzureTableStorage <ClientKeysToBlobKeyEntity> .Create( _settings.ConnectionString(x => x.Db.DataConnString), ClientKeysToBlobKeys.TableName, _log)))) .As <IClientDictionary>() .SingleInstance(); builder.Populate(_services); }
public void ActivityHelperConstructor_ThrowsArgumentNullException() { var logger = new Mock <ILogger <ActivityHelper <MainDialog> > >().Object; var localizer = new Mock <IStringLocalizer <Strings> >().Object; turnContextMock = new Mock <ITurnContext>(); IStorage storage = new AzureBlobStorage(ConfigurationData.storageOptions.Value.ConnectionString, "bot-state"); UserState userState = new UserState(storage); ConversationState conversationState = new ConversationState(storage); var loggerMainDialog = new Mock <ILogger <MainDialog> >().Object; MainDialog mainDialog = new MainDialog( ConfigurationData.tokenOptions, loggerMainDialog, localizer); constructor_ArgumentNullException = new ActivityHelper <MainDialog>( logger, userState, teamStorageProvider.Object, localizer, mainDialog, conversationState, teamMembership.Object, userProfile.Object, introductionStorageProvider.Object, sharePointHelper.Object, introductionCardHelper.Object, graphUtility.Object, welcomeCardFactory.Object, null, userStorageProvider.Object, null, feedbackProvider.Object, imageUploadProvider.Object); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddBot <PictureBot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); var middleware = options.Middleware; IStorage conversationDataStore = new MemoryStorage(); IStorage userDataStore = new AzureBlobStorage("DefaultEndpointsProtocol=https;AccountName=anthobotsa;AccountKey=qQg8+8wcZTS+whtPlypm7LQTfDhU881VDfoO6m0AhSvIOd5yyakcirD2wzRbsqDzBEhEbo5s/rNU7cSadseLkw==;EndpointSuffix=core.windows.net", "userdatastore"); // Add middleware below middleware.Add(new UserState <UserData>(userDataStore)); middleware.Add(new ConversationState <ConversationInfo>(conversationDataStore)); middleware.Add(new CosmosMiddleware()); // Add Regex ability below middleware.Add(new RegExpRecognizerMiddleware() .AddIntent("search", new Regex("search picture(?:s)*(.*)|search pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("share", new Regex("share picture(?:s)*(.*)|share pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("order", new Regex("order picture(?:s)*(.*)|order print(?:s)*(.*)|order pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("help", new Regex("help(.*)", RegexOptions.IgnoreCase))); // Add LUIS ability below middleware.Add(new LuisRecognizerMiddleware( new LuisModel("LuisAppId", "LuisKey", new Uri("LuisUri")))); }); }
public static IServiceProvider BindAndBuild(IConfigurationRoot configuration) { var collection = new ServiceCollection(); collection.AddTransient <Job>(); collection.AddTransient <Func <string, IQueueExt> >(x => queueName => AzureQueueExt.Create(new FakeReloadingManager(configuration.GetConnectionString("azure")), queueName)); collection.AddSingleton <IBlobStorage>(AzureBlobStorage.Create(new FakeReloadingManager(configuration.GetConnectionString("azure")))); var mongoClient = new MongoClient(configuration.GetConnectionString("mongo")); collection.AddSingleton <ISpentOutputRepository>(new SpentOutputRepository(new MongoStorage <OutputEntity>(mongoClient, "SpentOutputs"))); collection.AddSingleton <IBroadcastedOutputRepository>( new BroadcastedOutputRepository(new MongoStorage <BroadcastedOutputEntity>(mongoClient, "BroadcastedOutputs"))); collection.AddSingleton <IBroadcastedTransactionRepository>( new BroadcastedTransactionRepository(new MongoStorage <BroadcastedTransactionEntity>(mongoClient, "BroadcastedTransactions"))); collection.AddSingleton <IPaidFeesTaskWriter, PaidFeesTaskWriter>(); collection.AddSingleton <IPaidFeesRepository>( new PaidFeesRepository(new MongoStorage <PaidFeesEntity>(mongoClient, "PaidFees"))); collection.AddSingleton <ITransactionSignRequestRepository>( new TransactionSignRequestRepository(new MongoStorage <TransactionSignRequestEntity>(mongoClient, "SignRequests"))); collection.AddSingleton <IConfiguration>(configuration); return(collection.BuildServiceProvider()); }
private void RegisterBlob(ContainerBuilder builder) { builder.RegisterInstance( new TransactionBlobStorage( AzureBlobStorage.Create(_settings.Nested(p => p.Bitcoin.Db.DataConnString)))) .As <ITransactionBlobStorage>(); }
protected override void ConfigureContainerExt(ContainerBuilder builder) { builder.RegisterType <QuoteSubscriber>() .As <IStartable>() .AutoActivate() .SingleInstance(); builder.RegisterType <TradeSubscriber>() .As <IStartable>() .AutoActivate() .SingleInstance(); builder.RegisterType <ConnectionFactory>() .AsSelf() .WithParameter(TypedParameter.From(Config.DbSettings.DataConnectionString)) .SingleInstance(); builder.RegisterType <QuoteRepository>() .SingleInstance(); builder.RegisterType <QuoteMemoryCache <Quote> >() .SingleInstance(); var azureBlobStorage = AzureBlobStorage.Create(Config.AzureStorage.ConnectionString, TimeSpan.FromMinutes(1)); builder.RegisterInstance(azureBlobStorage) .As <IBlobStorage>() .SingleInstance(); }
public EchoBot(BotServices botService, EchoBotAccessors accessors) { _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors)); var blobStorage = botService.GetConnectedService(ServiceTypes.BlobStorage, "bot-data") as BlobStorageService; dataStore = new AzureBlobStorage(blobStorage.ConnectionString, blobStorage.Container); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddBot <PictureBot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); var middleware = options.Middleware; IStorage conversationDataStore = new MemoryStorage(); IStorage userDataStore = new AzureBlobStorage("ConnectionStringHere", "userdatastore"); // Add middleware below middleware.Add(new UserState <UserData>(userDataStore)); middleware.Add(new ConversationState <ConversationInfo>(conversationDataStore)); middleware.Add(new CosmosMiddleware()); // Add Regex ability below middleware.Add(new RegExpRecognizerMiddleware() .AddIntent("search", new Regex("search picture(?:s)*(.*)|search pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("share", new Regex("share picture(?:s)*(.*)|share pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("order", new Regex("order picture(?:s)*(.*)|order print(?:s)*(.*)|order pic(?:s)*(.*)", RegexOptions.IgnoreCase)) .AddIntent("help", new Regex("help(.*)", RegexOptions.IgnoreCase))); // Add LUIS ability below middleware.Add(new LuisRecognizerMiddleware( new LuisModel("LuisAppId", "LuisKey", new Uri("LuisUri")))); }); }
public App() { //MAKE THIS ASYNC AND PULL THIS OUT OF THE CONSTRUCTOR MyAzureBlobStorage = new AzureBlobStorage(); MyCloudBlobClient = MyAzureBlobStorage.CreateCloudBlobClient(); MyCloudBlobContainer = MyAzureBlobStorage.CreateCloudBlobClientAndContainer(ContainerName); string dbPath = FileAccessHelper.GetLocalFilePath("asa16dog6.db3"); //USE THIS FOR LIST PAGE DogRep = new DogRepository(dbPath); //USE THIS FOR LIST PHOTO PAGE DogPhotoRep = new DogPhotoRepository(dbPath); //USE THIS FOR LIST PHOTO BASE SIXTY FOUR PAGE DogRepBaseSixtyFour = new DogRepositoryBaseSixtyFour(dbPath); DogRepBlob = new DogRepositoryBlob(dbPath); var applicationStartPage = new FirstPage(); var myNavigationPage = new NavigationPage(applicationStartPage); MainPage = myNavigationPage; //Initialize Dog Photo View Page MyDogListMVVMPage = new DogListMVVMPage(); MyDogListPhotoPage = new DogListPhotoPage(); MyDogListPhotoBase64Page = new DogListPhotoBase64Page(); MyDogListPhotoBlobPage = new DogListPhotoBlobPage(); }
private void RegisterServices(ContainerBuilder builder) { builder .Register(ctx => new BlobUploader( AzureBlobStorage.Create( _settingsManager.ConnectionString(x => x.HistoryExportBuilderJob.Db.DataConnString)))) .As <IFileUploader>() .SingleInstance(); builder .Register(ctx => new IdMappingsRepository( AzureTableStorage <IdMappingEntity> .Create( _settingsManager.ConnectionString(x => x.HistoryExportBuilderJob.Db.DataConnString), IdMappingsRepository.TableName, ctx.Resolve <ILogFactory>()))) .As <IFileMapper>() .SingleInstance(); builder .Register(ctx => new ExpiryEntryRepository( AzureTableStorage <ExpiryEntryEntity> .Create( _settingsManager.ConnectionString(x => x.HistoryExportBuilderJob.Db.DataConnString), ExpiryEntryRepository.TableName, ctx.Resolve <ILogFactory>()))) .As <IExpiryWatcher>() .SingleInstance(); builder .RegisterType <CsvMaker>() .As <IFileMaker>() .SingleInstance(); }
protected override void Load(ContainerBuilder builder) { const string invoicesTableName = "Invoices"; const string invoiceFilesTableName = "InvoiceFiles"; const string employeesTableName = "Employees"; const string invoiceHistoryTableName = "InvoiceHistory"; const string merchantSettingTableName = "MerchantSettings"; const string paymentRequestHistoryTableName = "PaymentRequestHistory"; const string invoiceDisputeTableName = "InvoiceDispute"; const string invoicePayerHistoryTableName = "InvoicePayerHistory"; builder.Register(c => new FileRepository(AzureBlobStorage.Create(_connectionString))) .As <IFileRepository>() .SingleInstance(); builder.Register(c => new FileInfoRepository(CreateTable <FileInfoEntity>(invoiceFilesTableName, c.Resolve <ILogFactory>()))) .As <IFileInfoRepository>() .SingleInstance(); builder.Register(c => new InvoiceRepository(CreateTable <InvoiceEntity>(invoicesTableName, c.Resolve <ILogFactory>()), CreateTable <AzureIndex>(invoicesTableName, c.Resolve <ILogFactory>()), CreateTable <AzureIndex>(invoicesTableName, c.Resolve <ILogFactory>()))) .As <IInvoiceRepository>() .SingleInstance(); builder.Register(c => new EmployeeRepository(CreateTable <EmployeeEntity>(employeesTableName, c.Resolve <ILogFactory>()), CreateTable <AzureIndex>(employeesTableName, c.Resolve <ILogFactory>()))) .As <IEmployeeRepository>() .SingleInstance(); builder.Register(c => new HistoryRepository(CreateTable <HistoryItemEntity>(invoiceHistoryTableName, c.Resolve <ILogFactory>()))) .As <IHistoryRepository>() .SingleInstance(); builder.Register(c => new MerchantSettingRepository(CreateTable <MerchantSettingEntity>(merchantSettingTableName, c.Resolve <ILogFactory>()))) .As <IMerchantSettingRepository>() .SingleInstance(); builder.Register(c => new PaymentRequestHistoryRepository(CreateTable <PaymentRequestHistoryItemEntity>(paymentRequestHistoryTableName, c.Resolve <ILogFactory>()))) .As <IPaymentRequestHistoryRepository>() .SingleInstance(); builder.Register(c => new InvoiceDisputeRepository(CreateTable <InvoiceDisputeEntity>(invoiceDisputeTableName, c.Resolve <ILogFactory>()))) .As <IInvoiceDisputeRepository>() .SingleInstance(); builder.Register(c => new InvoicePayerHistoryRepository(CreateTable <InvoicePayerHistoryEntity>(invoicePayerHistoryTableName, c.Resolve <ILogFactory>()))) .As <IInvoicePayerHistoryRepository>() .SingleInstance(); }
public static IBlockchainIndexationStateRepository Create( IReloadingManager <string> connectionString) { return(new DefaultBlockchainIndexationStateRepository ( AzureBlobStorage.Create(connectionString) )); }
public static IRawObjectReadOnlyRepository Create( string integrationName, IReloadingManager <string> connectionString) { var blob = AzureBlobStorage.Create(connectionString); return(new RawObjectReadOnlyRepository(integrationName, blob)); }
private AzureBlobStorage ConfigureStateDataStore(IConfiguration configuration) { AzureBlobStorage azureBlobStorage = new AzureBlobStorage( configuration["ConnectionStrings:StorageAccount"], configuration["Data:SessionStateTable"]); return(azureBlobStorage); }
public static T ReadGeneralSettings <T>(string connectionString, string container, string fileName) { var settingsStorage = new AzureBlobStorage(connectionString); var settingsData = settingsStorage.GetAsync(container, fileName).Result.ToBytes(); var str = Encoding.UTF8.GetString(settingsData); return(Newtonsoft.Json.JsonConvert.DeserializeObject <T>(str)); }
public static IBalanceCheckSchedulerLockRepository Create( IReloadingManager <string> connectionString) { return(new DefaultBalanceCheckSchedulerLockRepository ( AzureBlobStorage.Create(connectionString) )); }
static async Task Main(string[] args) { var hostBuilder = new HostBuilder() .ConfigureAppConfiguration((hostingContext, config) => { config.AddEnvironmentVariables(); }) .ConfigureServices((hostContext, services) => { var settings = SettingsParser.Parse(args); services .AddScoped(_ => CloudStorageAccount.Parse(settings.ConnectionString)) .AddScoped(p => new MigrationContext( p.GetRequiredService <CloudStorageAccount>(), settings.Tags, settings.Properties)) .AddScoped(p => { var context = p.GetRequiredService <MigrationContext>(); var container = context.BlobClient.GetContainerReference(settings.Container); var blob = container.GetBlockBlobReference(settings.Blob); var storage = new AzureBlobStorage(blob); var assembly = LoadAssembly(settings.Assembly); return(new MigrationRunner( storage, new DefaultMigrationFinder( new DefaultMigrationFactory(), assembly))); }) ; }) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); }) .UseConsoleLifetime() ; using (var host = hostBuilder.Build()) { var applicationLifetime = host.Services.GetRequiredService <IApplicationLifetime>(); await host.StartAsync(); using (var scope = host.Services.CreateScope()) { var runner = host.Services.GetRequiredService <MigrationRunner>(); var context = host.Services.GetRequiredService <MigrationContext>(); await runner.RunAsync(context, applicationLifetime.ApplicationStopping); } await host.StopAsync(); } }