Exemple #1
0
        private static async Task InitAndRunAsync()
        {
            var instrumentationKey = await AzureStorage.GetAppInsightsInstrumentationKeyAsync(Environment.GetEnvironmentVariable("ApplicationInsightsAccountName"));

            var defaultStorageAccountName = Environment.GetEnvironmentVariable("DefaultStorageAccountName");
            var cromwellUrl = ConfigurationManager.AppSettings.Get("CromwellUrl");

            var serviceCollection = new ServiceCollection()
                                    .AddLogging(loggingBuilder =>
            {
                if (!string.IsNullOrWhiteSpace(instrumentationKey))
                {
                    loggingBuilder.AddApplicationInsights(instrumentationKey);
                }
                else
                {
                    Console.WriteLine("Warning: AppInsights key was null, and so AppInsights logging will not be enabled.  Check if this VM has Contributor access to the Application Insights instance.");
                }

                loggingBuilder.AddConsole();
            });

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var environment = new CromwellOnAzureEnvironment(
                serviceProvider.GetRequiredService <ILoggerFactory>(),
                new AzureStorage(serviceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <AzureStorage>(), defaultStorageAccountName),
                new CromwellApiClient.CromwellApiClient(cromwellUrl));

            serviceCollection.AddSingleton(s => new TriggerEngine(s.GetRequiredService <ILoggerFactory>(), environment));
            serviceProvider = serviceCollection.BuildServiceProvider();
            var engine = serviceProvider.GetService <TriggerEngine>();
            await engine.RunAsync();
        }
Exemple #2
0
        private static async Task InitAndRunAsync()
        {
            var instrumentationKey = await AzureStorage.GetAppInsightsInstrumentationKeyAsync(Environment.GetEnvironmentVariable("ApplicationInsightsAccountName"));

            var defaultStorageAccountName = Environment.GetEnvironmentVariable("DefaultStorageAccountName");
            var cosmosDbAccountName       = Environment.GetEnvironmentVariable("CosmosDbAccountName");
            var cromwellUrl = ConfigurationManager.AppSettings.Get("CromwellUrl");

            var serviceCollection = new ServiceCollection()
                                    .AddLogging(loggingBuilder =>
            {
                if (!string.IsNullOrWhiteSpace(instrumentationKey))
                {
                    loggingBuilder.AddApplicationInsights(instrumentationKey,
                                                          options =>
                    {
                        options.TrackExceptionsAsExceptionTelemetry = false;
                    });
                }
                else
                {
                    Console.WriteLine("Warning: AppInsights key was null, and so AppInsights logging will not be enabled.  Check if this VM has Contributor access to the Application Insights instance.");
                }

                loggingBuilder.AddConsole();
            });

            var serviceProvider = serviceCollection.BuildServiceProvider();

            (var storageAccounts, var storageAccount) = await AzureStorage.GetStorageAccountsUsingMsiAsync(defaultStorageAccountName);

            (var cosmosDbEndpoint, var cosmosDbKey) = await GetCosmosDbEndpointAndKeyAsync(cosmosDbAccountName);

            var environment = new CromwellOnAzureEnvironment(
                serviceProvider.GetRequiredService <ILoggerFactory>(),
                storageAccount,
                new CromwellApiClient.CromwellApiClient(cromwellUrl),
                new CosmosDbRepository <TesTask>(
                    cosmosDbEndpoint,
                    cosmosDbKey,
                    Constants.CosmosDbDatabaseId,
                    Constants.CosmosDbContainerId,
                    Constants.CosmosDbPartitionId),
                storageAccounts);

            serviceCollection.AddSingleton(s => new TriggerEngine(s.GetRequiredService <ILoggerFactory>(), environment, TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(30)));
            serviceProvider = serviceCollection.BuildServiceProvider();
            var engine = serviceProvider.GetService <TriggerEngine>();
            await engine.RunAsync();
        }
Exemple #3
0
 public TriggerEngine(ILoggerFactory loggerFactory, CromwellOnAzureEnvironment environment)
 {
     logger           = loggerFactory.CreateLogger <TriggerEngine>();
     this.environment = environment;
 }