예제 #1
0
 /// <summary>
 /// The constructor
 /// </summary>
 /// <param name="configuration"><see cref="IConfiguration"/></param>
 /// <param name="azureProxy"><see cref="IAzureProxy"/></param>
 /// <param name="storageAccessProvider"><see cref="IStorageAccessProvider"/></param>
 /// <param name="logger"><see cref="ILogger"/></param>
 public ConfigurationUtils(IConfiguration configuration, IAzureProxy azureProxy, IStorageAccessProvider storageAccessProvider, ILogger logger)
 {
     this.configuration         = configuration;
     this.azureProxy            = azureProxy;
     this.storageAccessProvider = storageAccessProvider;
     this.logger = logger;
 }
예제 #2
0
        private void ConfigureServices(IServiceCollection services, IAppCache cache, AzureProxy azureProxy, IAzureProxy cachingAzureProxy, IStorageAccessProvider storageAccessProvider, IRepository <TesTask> repository)
        => services.AddSingleton(cache)

        .AddSingleton(cachingAzureProxy)
        .AddSingleton(azureProxy)

        .AddControllers()
        .AddNewtonsoftJson(opts =>
        {
            opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
        }).Services

        .AddSingleton <IRepository <TesTask> >(new CachingWithRetriesRepository <TesTask>(repository))
        .AddSingleton <IBatchScheduler>(new BatchScheduler(loggerFactory.CreateLogger <BatchScheduler>(), Configuration, cachingAzureProxy, storageAccessProvider))

        .AddSwaggerGen(c =>
        {
            c.SwaggerDoc("0.3.0", new OpenApiInfo
            {
                Version     = "0.3.0",
                Title       = "Task Execution Service",
                Description = "Task Execution Service (ASP.NET Core 3.1)",
                Contact     = new OpenApiContact()
                {
                    Name = "Microsoft Genomics",
                    Url  = new Uri("https://github.com/microsoft/CromwellOnAzure")
                },
            });
            c.CustomSchemaIds(type => type.FullName);
            c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml");
            c.OperationFilter <GeneratePathParamsValidationFilter>();
        })

        .AddHostedService <Scheduler>()
        .AddHostedService <DeleteCompletedBatchJobsHostedService>()
        .AddHostedService <DeleteOrphanedBatchJobsHostedService>()
        .AddHostedService <DeleteOrphanedAutoPoolsHostedService>()
        .AddHostedService <RefreshVMSizesAndPricesHostedService>()

        // Configure AppInsights Azure Service when in PRODUCTION environment
        .IfThenElse(hostingEnvironment.IsProduction(),
                    s =>
        {
            var applicationInsightsAccountName = Configuration["ApplicationInsightsAccountName"];
            var instrumentationKey             = AzureProxy.GetAppInsightsInstrumentationKeyAsync(applicationInsightsAccountName).Result;

            if (instrumentationKey is not null)
            {
                return(s.AddApplicationInsightsTelemetry(instrumentationKey));
            }

            return(s);
        },
                    s => s.AddApplicationInsightsTelemetry());