Exemple #1
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
            var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
            var databaseConnectionString            = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);

            _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString);

            _targetDatabase            = new SqlConnectionStringBuilder(databaseConnectionString);
            _azureCdnAccountNumber     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
            _azureCdnPlatform          = ValidateAzureCdnPlatform(azureCdnPlatform);
            _cloudStorageContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName));

            _aggregatesOnly = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.AggregatesOnly);

            // construct a cloud blob client for the configured storage account
            _cloudBlobClient = _cloudStorageAccount.CreateCloudBlobClient();
            _cloudBlobClient.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(10), 5);

            // Get the source blob container (containing compressed log files)
            // and construct a log source (fetching raw logs from the source blob container)
            var sourceBlobContainer = _cloudBlobClient.GetContainerReference(_cloudStorageContainerName);

            _blobLeaseManager = new LogFileProvider(sourceBlobContainer, LoggerFactory);
        }
Exemple #2
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            _whatIf = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.WhatIf);

            var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryDatabase);

            _galleryDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

            _galleryBrand      = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryBrand);
            _galleryAccountUrl = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryAccountUrl);

            _mailFrom = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.MailFrom);

            var smtpConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SmtpUri);
            var smtpUri = new SmtpUri(new Uri(smtpConnectionString));

            _smtpClient = CreateSmtpClient(smtpUri);

            _warnDaysBeforeExpiration = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.WarnDaysBeforeExpiration)
                                        ?? _warnDaysBeforeExpiration;

            _allowEmailResendAfterDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.AllowEmailResendAfterDays)
                                         ?? _allowEmailResendAfterDays;

            var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
            var storageContainerName    = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);

            var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            var storageFactory = new AzureStorageFactory(storageAccount, storageContainerName, LoggerFactory);

            _storage = storageFactory.Create();
        }
Exemple #3
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                // Init member variables
                Source =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.SourceDatabase,
                                                            EnvironmentVariableKeys.SqlGallery));
                Destination =
                    new SqlConnectionStringBuilder(
                        JobConfigurationManager.GetArgument(jobArgsDictionary,
                                                            JobArgumentNames.DestinationDatabase,
                                                            EnvironmentVariableKeys.SqlWarehouse));

                MinTimestamp         = JobConfigurationManager.TryGetDateTimeArgument(jobArgsDictionary, "MinTimestamp");
                MaxTimestamp         = JobConfigurationManager.TryGetDateTimeArgument(jobArgsDictionary, "MaxTimestamp");
                ClearExistingRecords = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, "Clear");

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
Exemple #4
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            ServicePointManager.DefaultConnectionLimit = MaximumConnectionsPerServer;
            _validateOnly          = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, ValidateArgument, defaultValue: false);
            ConfigurationValidated = false;

            base.Init(serviceContainer, jobArgsDictionary);
        }
Exemple #5
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            base.Init(serviceContainer, jobArgsDictionary);

            _preinstalledSetPath  = JobConfigurationManager.TryGetArgument(jobArgsDictionary, RebuildPreinstalledSetArgumentName);
            _initialize           = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, InitializeArgumentName);
            _verifyInitialization = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, VerifyInitializationArgumentName);
        }
Exemple #6
0
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            var configurationFilename = JobConfigurationManager.GetArgument(jobArgsDictionary, ConfigurationArgument);

            _validateOnly          = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, ValidateArgument, defaultValue: false);
            _serviceProvider       = GetServiceProvider(GetConfigurationRoot(configurationFilename, _validateOnly));
            ConfigurationValidated = false;
        }
Exemple #7
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            ServicePointManager.DefaultConnectionLimit = MaximumConnectionsPerServer;

            var configurationFilename = JobConfigurationManager.GetArgument(jobArgsDictionary, ConfigurationArgument);

            _validateOnly = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, ValidateArgument, defaultValue: false);

            var configurationRoot = GetConfigurationRoot(configurationFilename, _validateOnly, out var secretInjector);

            _serviceProvider = GetServiceProvider(configurationRoot, secretInjector);

            ConfigurationValidated = false;
        }
Exemple #8
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(ConsoleLogOnly);
                var loggerFactory       = LoggingSetup.CreateLoggerFactory(loggerConfiguration);
                _logger = loggerFactory.CreateLogger <Job>();

                _whatIf = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.WhatIf);

                var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryDatabase);
                _galleryDatabase = new SqlConnectionStringBuilder(databaseConnectionString);

                _galleryBrand      = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryBrand);
                _galleryAccountUrl = JobConfigurationManager.GetArgument(jobArgsDictionary, MyJobArgumentNames.GalleryAccountUrl);

                _mailFrom = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.MailFrom);

                var smtpConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SmtpUri);
                var smtpUri = new SmtpUri(new Uri(smtpConnectionString));
                _smtpClient = CreateSmtpClient(smtpUri);

                _warnDaysBeforeExpiration = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.WarnDaysBeforeExpiration)
                                            ?? _warnDaysBeforeExpiration;

                _allowEmailResendAfterDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.AllowEmailResendAfterDays)
                                             ?? _allowEmailResendAfterDays;

                var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
                var storageContainerName    = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);

                var csa            = CloudStorageAccount.Parse(storageConnectionString);
                var storageFactory = new AzureStorageFactory(csa, storageContainerName, loggerFactory);
                _storage = storageFactory.Create();
            }
            catch (Exception exception)
            {
                _logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!");

                return(false);
            }

            return(true);
        }
Exemple #9
0
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
                ApplicationInsights.Initialize(instrumentationKey);

                var loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(ConsoleLogOnly);
                _loggerFactory = LoggingSetup.CreateLoggerFactory(loggerConfiguration);
                _logger        = _loggerFactory.CreateLogger <Job>();

                var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
                var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
                var databaseConnectionString            = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
                _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString);

                _targetDatabase            = new SqlConnectionStringBuilder(databaseConnectionString);
                _azureCdnAccountNumber     = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
                _azureCdnPlatform          = ValidateAzureCdnPlatform(azureCdnPlatform);
                _cloudStorageContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName));

                _aggregatesOnly = JobConfigurationManager.TryGetBoolArgument(jobArgsDictionary, JobArgumentNames.AggregatesOnly);

                // construct a cloud blob client for the configured storage account
                _cloudBlobClient = _cloudStorageAccount.CreateCloudBlobClient();
                _cloudBlobClient.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(10), 5);

                // Get the source blob container (containing compressed log files)
                // and construct a log source (fetching raw logs from the source blob container)
                var sourceBlobContainer = _cloudBlobClient.GetContainerReference(_cloudStorageContainerName);
                _blobLeaseManager = new LogFileProvider(sourceBlobContainer, _loggerFactory);
            }
            catch (Exception exception)
            {
                _logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!");

                return(false);
            }

            return(true);
        }