Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            StartupService.ConfigureServices(services, Configuration);

            // Add framework services.
            services.AddMvc();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string[] initialScopes = Configuration.GetValue <string>("DownstreamApi:Scopes")?.Split(' ') ?? Array.Empty <string>();

            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
            .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"))
            .EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
            .AddMicrosoftGraph(Configuration.GetSection("DownstreamApi"))
            .AddInMemoryTokenCaches();

            services.AddControllersWithViews(options =>
            {
                var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
                options.Filters.Add(new AuthorizeFilter(policy));
            });

            services.AddRazorPages().AddMicrosoftIdentityUI();

            StartupService.ConfigureServices(services);
        }
        static Task Main(string[] args)
        {
            var host = new HostBuilder()
                       .ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddCommandLine(args))
                       .ConfigureFunctionsWorkerDefaults()
                       .ConfigureServices(services =>
            {
                // Add Logging
                services.AddLogging();

                // Add HttpClient
                services.AddHttpClient();

                // Add Custom Services
                services.AddSingleton <QueueClient>(new QueueClient(_storageConnectionString, QueueConstants.RemainingRepositoriesQueue));
                StartupService.ConfigureServices(services, _token, options => options.UseSqlServer(_connectionString));
            })
                       .Build();

            return(host.RunAsync());
        }
Beispiel #4
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     builder.Services.AddSingleton <CloudQueueClient>(CloudStorageAccount.Parse(_storageConnectionString).CreateCloudQueueClient());
     StartupService.ConfigureServices(builder.Services);
 }