Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options => { options.Filters.Add(typeof(ApiExceptionFilter)); });

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist/AzureSpeedFrontend";
            });

            services.AddCors("CorsPolicy");

            services.AddSingleton <IFileProvider>(this.webHostEnvironment.ContentRootFileProvider);
            services.AddSingleton <IAzureIPInfoProvider, AzureIPInfoProvider>();
            services.AddSingleton <ILegacyAzureIPInfoProvider, LegacyAzureIPInfoProvider>(serviceProvider =>
            {
                var localDataStoreContext = new LegacyAzureIPInfoProvider(webHostEnvironment.ContentRootPath);
                return(localDataStoreContext);
            });
            services.AddSingleton <StorageAccountsContext>(serviceProvider =>
            {
                var localDataStoreContext = new StorageAccountsContext(webHostEnvironment.ContentRootPath);
                return(localDataStoreContext);
            });
        }
Example #2
0
 public ApiController(
     IHttpClientFactory httpClientFactory,
     ILogger <ApiController> logger,
     StorageAccountsContext storageAccountsContext)
 {
     this.httpClientFactory      = httpClientFactory;
     this.storageAccountsContext = storageAccountsContext;
     this.logger = logger;
 }
Example #3
0
 public ApiController(
     IAzureIPInfoProvider azureIPInfoProvider,
     IFileProvider fileProvider,
     ILogger <ApiController> logger,
     StorageAccountsContext storageAccountsContext)
 {
     this.azureIPInfoProvider    = azureIPInfoProvider;
     this.fileProvider           = fileProvider;
     this.storageAccountsContext = storageAccountsContext;
     this.logger = logger;
 }
Example #4
0
        public async Task InitializeAsync()
        {
            var localDataStoreContext = new StorageAccountsContext(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            foreach (var account in localDataStoreContext.StorageAccounts.ToList())
            {
                if (account.Name != "asteastasia")
                {
                    // continue;
                }

                var storageContext = new StorageContext(account);

                Console.WriteLine($"[{account.Name}] Starting configure storage account");

                await storageContext.EnableLoggingAsync();

                Console.WriteLine($"[{account.Name}] Enable logging completed successfully");

                await storageContext.EnableCORSAsync();

                Console.WriteLine($"[{account.Name}] Successfully enabled CORS");

                await storageContext.CreatePublicContainerAsync();

                Console.WriteLine($"[{account.Name}] Successfully created public container");

                await storageContext.CreatePrivateContainerAsync(AzureSpeedConstants.PrivateContainerName);

                Console.WriteLine($"[{account.Name}] Successfully created private container");

                await storageContext.CreatePrivateContainerAsync(AzureSpeedConstants.UploadContainerName);

                Console.WriteLine($"[{account.Name}] Successfully created upload container");

                await storageContext.Upload100MBBlobAsync();

                Console.WriteLine($"[{account.Name}] Successfully uploaded 100MB.bin blob");

                Console.WriteLine($"[{account.Name}] Successfully initialized storage account");
            }

            Console.WriteLine("Successfully completed all storage accounts configuration");
        }
Example #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options => { options.Filters.Add(typeof(ApiExceptionFilter)); });

            services.AddCors("CorsPolicy");

            services.AddSingleton <IFileProvider>(this.webHostEnvironment.ContentRootFileProvider);
            services.AddSingleton <IAzureIPInfoProvider, AzureIPInfoProvider>();
            services.AddSingleton <ILegacyAzureIPInfoProvider, LegacyAzureIPInfoProvider>(serviceProvider =>
            {
                var localDataStoreContext = new LegacyAzureIPInfoProvider(webHostEnvironment.ContentRootPath);
                return(localDataStoreContext);
            });
            services.AddSingleton <StorageAccountsContext>(serviceProvider =>
            {
                var localDataStoreContext = new StorageAccountsContext(webHostEnvironment.ContentRootPath);
                return(localDataStoreContext);
            });
        }
Example #6
0
 public LocalDataStoreContextTest()
 {
     this.storageAccountsContext = new StorageAccountsContext(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
 }