Exemple #1
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables().Build();

            config.Bind("Nexus", NexusSettings);

            FulcrumApplicationHelper.WebBasicSetup($"async-caller-function-app-{NexusSettings.ServiceTenant.Organization}-{NexusSettings.ServiceTenant.Environment}", NexusSettings.ServiceTenant, NexusSettings.RuntimeLevel);

            var nexusServiceCredentials = new AuthenticationCredentials {
                ClientId = NexusSettings.Authentication.ClientId, ClientSecret = NexusSettings.Authentication.ClientSecret
            };
            var loggingConfiguration = new LeverServiceConfiguration(NexusSettings.ServiceTenant, "logging", NexusSettings.FundamentalsUrl, nexusServiceCredentials, NexusSettings.FundamentalsUrl);
            var logClient            = new LogClient("http://this.will.be.ignored", new BasicAuthenticationCredentials());
            var logger = new FulcrumLogger(logClient, loggingConfiguration);

            FulcrumApplication.Setup.SynchronousFastLogger = logger;

            AsyncCallerServiceConfiguration = new Dictionary <Tenant, ILeverServiceConfiguration>
            {
                // Add service tenant
                [NexusSettings.ServiceTenant] = new LeverServiceConfiguration(
                    NexusSettings.ServiceTenant, "AsyncCaller", NexusSettings.FundamentalsUrl, nexusServiceCredentials,
                    NexusSettings.FundamentalsUrl)
            };
            Log.LogInformation($"[Startup] CONFIGURATION for service tenant {NexusSettings.ServiceTenant}: {nexusServiceCredentials.ClientId} @ {NexusSettings.FundamentalsUrl}");

            // Check for additional tenant credentials
            if (NexusSettings.Authentication.ExtraTenants != null)
            {
                foreach (var tenantCredentials in NexusSettings.Authentication.ExtraTenants)
                {
                    try
                    {
                        var serviceCredentials = new AuthenticationCredentials {
                            ClientId = tenantCredentials.ClientId, ClientSecret = tenantCredentials.ClientSecret
                        };
                        AsyncCallerServiceConfiguration[tenantCredentials.Tenant] = new LeverServiceConfiguration(
                            tenantCredentials.Tenant, "AsyncCaller", NexusSettings.FundamentalsUrl, serviceCredentials,
                            NexusSettings.FundamentalsUrl);
                        Log.LogInformation($"[Startup] CONFIGURATION for extra tenant {tenantCredentials.Tenant}: {tenantCredentials.ClientId} @ {NexusSettings.FundamentalsUrl}");
                    }
                    catch (Exception e)
                    {
                        Log.LogError($"Error setting up configuration for {tenantCredentials.Tenant}: {e.Message}", e);
                    }
                }
            }
        }
        /// <summary></summary>
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup <Startup>();
        })
        .ConfigureServices((context, services) =>
        {
            var nexusSettings = context.Configuration.GetSection("Nexus");
            FulcrumApplicationHelper.WebBasicSetup(nexusSettings);

            services.AddHostedService <PurgeJob>();
        })
        .ConfigureLogging((context, loggingBuilder) =>
        {
            FulcrumApplication.Setup.SynchronousFastLogger = new DebugTraceLogger();         // TODO
        });
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var nexusSettings = Configuration.GetSection("Nexus");

            FulcrumApplicationHelper.WebBasicSetup(nexusSettings);

            services.AddControllers()
            .AddNewtonsoftJson(options =>
            {
                options.UseCamelCasing(true);
                options.SerializerSettings.Converters.Add(new StringEnumConverter());
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Mocks", Version = "v1"
                });
            });

            ConfigureNexus(services);
        }
Exemple #4
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables().Build();

            config.Bind("Nexus", NexusSettings);

            FulcrumApplicationHelper.WebBasicSetup($"async-caller-function-app-{NexusSettings.ServiceTenant.Organization}-{NexusSettings.ServiceTenant.Environment}", NexusSettings.ServiceTenant, NexusSettings.RuntimeLevel);

            var nexusServiceCredentials = new AuthenticationCredentials {
                ClientId = NexusSettings.Authentication.ClientId, ClientSecret = NexusSettings.Authentication.ClientSecret
            };
            var loggingConfiguration = new LeverServiceConfiguration(NexusSettings.ServiceTenant, "logging", NexusSettings.FundamentalsUrl, nexusServiceCredentials, NexusSettings.FundamentalsUrl);
            var logClient            = new LogClient("http://this.will.be.ignored", new BasicAuthenticationCredentials());
            var logger = new FulcrumLogger(logClient, loggingConfiguration);

            FulcrumApplication.Setup.SynchronousFastLogger = logger;

            AsyncCallerServiceConfiguration = new LeverServiceConfiguration(NexusSettings.ServiceTenant, "AsyncCaller", NexusSettings.FundamentalsUrl, nexusServiceCredentials, NexusSettings.FundamentalsUrl);
        }