Example #1
0
        /// <summary>
        ///     The main program entry-point.
        /// </summary>
        /// <param name="args">
        ///     Command-line arguments.
        /// </param>
        static async Task Main(string[] args)
        {
            await new HostBuilder()
            .ConfigureAppConfiguration((context, config) =>
            {
                config.AddJsonFile("appsettings.json");
                config.AddUserSecrets(
                    typeof(Program).Assembly
                    );
                config.AddEnvironmentVariables(prefix: "DAAS_");
            })
            .ConfigureLogging((context, logging) =>
            {
                Log.Logger = StandardLogging.ConfigureSerilog(context.Configuration,
                                                              daasComponentName: "Provisioning"
                                                              );

                logging.ClearProviders();
                logging.AddSerilog(Log.Logger);
            })
            .ConfigureServices((hostContext, services) =>
            {
                services.AddOptions();
                services.AddDaaSOptions(hostContext.Configuration);

                services.AddDaaSDataAccess(
                    createIndexes: true
                    );

                services.AddKubeClient();
                services.AddDatabaseProxyApiClient();
                services.AddVaultClient();
                services.AddProvisioning();

                DatabaseOptions databaseOptions = DatabaseOptions.From(hostContext.Configuration);
                if (String.IsNullOrWhiteSpace(databaseOptions.ConnectionString))
                {
                    throw new InvalidOperationException("Application configuration is missing database connection string.");
                }

                services.AddScoped <IHostedService, ProvisioningService>();
            })
            .RunConsoleAsync();
        }
Example #2
0
        /// <summary>
        ///     Create the application web host.
        /// </summary>
        /// <param name="args">
        ///     Command-line arguments.
        /// </param>
        /// <returns>
        ///     The <see cref="IWebHost"/>.
        /// </returns>
        public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((context, config) =>
        {
            config.AddJsonFile("appsettings.json");
            config.AddUserSecrets <Startup>();
            config.AddEnvironmentVariables(prefix: "DAAS_");
        })
        .ConfigureLogging((context, logging) =>
        {
            Log.Logger = StandardLogging.ConfigureSerilog(context.Configuration,
                                                          daasComponentName: "SQLExecutor"
                                                          );

            logging.ClearProviders();
            logging.AddSerilog(Log.Logger);
        })
        .Build();