public override bool Init(IDictionary <string, string> jobArgsDictionary) { string maxManifestSizeString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize); if (string.IsNullOrEmpty(maxManifestSizeString)) { MaxManifestSize = DefaultMaxAllowedManifestBytes; } else { MaxManifestSize = Convert.ToInt64(maxManifestSizeString); } PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase, EnvironmentVariableKeys.SqlGallery)); Source = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceStorage, EnvironmentVariableKeys.StorageGallery)); Backups = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.BackupStorage, EnvironmentVariableKeys.StorageGallery)); SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultSourceContainerName; BackupsContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.BackupContainerName) ?? DefaultBackupContainerName; SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName); BackupsContainer = Backups.CreateCloudBlobClient().GetContainerReference(BackupsContainerName); return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { WarehouseConnection = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DestinationDatabase, EnvironmentVariableKeys.SqlWarehouse)); Destination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination, EnvironmentVariableKeys.StoragePrimary)); DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName; DestinationContainer = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); string rankingCountString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.RankingCount); if (string.IsNullOrEmpty(rankingCountString)) { RankingCount = DefaultRankingCount; } else { RankingCount = Convert.ToInt32(rankingCountString); } return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); _loggerFactory = LoggingSetup.CreateLoggerFactory(); _logger = _loggerFactory.CreateLogger <Job>(); var ftpLogFolder = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourceUri); var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform); var cloudStorageAccount = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount); _cloudStorageContainerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName); _azureCdnAccountNumber = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber); _ftpUsername = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourceUsername); _ftpPassword = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.FtpSourcePassword); _ftpServerUri = ValidateFtpUri(ftpLogFolder); _azureCdnPlatform = ValidateAzureCdnPlatform(azureCdnPlatform); _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccount); } catch (Exception ex) { _logger.LogCritical("Job failed to initialize! {Exception}", ex); return(false); } return(true); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { var retrievedMaxManifestSize = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize); MaxManifestSize = retrievedMaxManifestSize == null ? DefaultMaxAllowedManifestBytes : Convert.ToInt64(retrievedMaxManifestSize); PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)); Source = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceStorage)); Backups = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.BackupStorage)); SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultSourceContainerName; BackupsContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.BackupContainerName) ?? DefaultBackupContainerName; ReadMeContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.ReadMeContainerName) ?? DefaultReadMeContainerName; SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName); BackupsContainer = Backups.CreateCloudBlobClient().GetContainerReference(BackupsContainerName); ReadMeContainer = Source.CreateCloudBlobClient().GetContainerReference(ReadMeContainerName); MaxTryCount = DefaultMaxRetryCount; }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { var packageDatabaseConnString = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)).ToString(); var statisticsDatabaseConnString = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase)).ToString(); var destination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination)); var destinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName; _destContainer = destination.CreateCloudBlobClient().GetContainerReference(destinationContainerName); _sqlExportScriptsToRun = new List <GenerateAuxiliaryData.SqlExporter> { new NestedJArrayExporter(packageDatabaseConnString, _destContainer, ScriptCuratedFeed, OutputNameCuratedFeed, Col0CuratedFeed, Col1CuratedFeed), new NestedJArrayExporter(packageDatabaseConnString, _destContainer, ScriptOwners, OutputNameOwners, Col0Owners, Col1Owners), new RankingsExporter(statisticsDatabaseConnString, _destContainer, ScriptRankingsTotal, ScriptRankingsProjectTypes, ScriptRankingsDistinctProjectTypes, OutputNameRankings) }; return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); _loggerFactory = LoggingSetup.CreateLoggerFactory(); _logger = _loggerFactory.CreateLogger <Job>(); var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString); _minAgeInDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, "MinAgeInDays") ?? DefaultMinAgeInDays; Trace.TraceInformation("Min age in days: " + _minAgeInDays); return(true); } catch (Exception exception) { _logger.LogCritical("Job failed to initialize. {Exception}", exception); } return(false); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); _loggerFactory = LoggingSetup.CreateLoggerFactory(); _logger = _loggerFactory.CreateLogger <Job>(); var statisticsDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); _statisticsDatabase = new SqlConnectionStringBuilder(statisticsDatabaseConnectionString); var destinationDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DestinationDatabase); _destinationDatabase = new SqlConnectionStringBuilder(destinationDatabaseConnectionString); } catch (Exception exception) { _logger.LogCritical("Failed to initialize job! {Exception}", exception); return(false); } return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); 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)); return(true); } catch (Exception exception) { ApplicationInsights.TrackException(exception); Trace.TraceError(exception.ToString()); } return(false); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { var packageDatabaseConnString = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)).ToString(); var statisticsDatabaseConnString = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase)).ToString(); var statisticsStorageAccount = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount)); var statisticsReportsContainerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName); var destination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination)); var destinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName; _destContainer = destination.CreateCloudBlobClient().GetContainerReference(destinationContainerName); _statisticsContainer = statisticsStorageAccount.CreateCloudBlobClient().GetContainerReference(statisticsReportsContainerName); _exportersToRun = new List <Exporter> { new VerifiedPackagesExporter(LoggerFactory.CreateLogger <VerifiedPackagesExporter>(), packageDatabaseConnString, _destContainer, ScriptVerifiedPackages, OutputNameVerifiedPackages), new NestedJArrayExporter(LoggerFactory.CreateLogger <NestedJArrayExporter>(), packageDatabaseConnString, _destContainer, ScriptCuratedFeed, OutputNameCuratedFeed, Col0CuratedFeed, Col1CuratedFeed), new NestedJArrayExporter(LoggerFactory.CreateLogger <NestedJArrayExporter>(), packageDatabaseConnString, _destContainer, ScriptOwners, OutputNameOwners, Col0Owners, Col1Owners), new RankingsExporter(LoggerFactory.CreateLogger <RankingsExporter>(), statisticsDatabaseConnString, _destContainer, ScriptRankingsTotal, OutputNameRankings), new BlobStorageExporter(LoggerFactory.CreateLogger <BlobStorageExporter>(), _statisticsContainer, StatisticsReportName, _destContainer, StatisticsReportName) }; }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)); Source = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source)); PrimaryDestination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination)); var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination); SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr); SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName; DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName; SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName); PrimaryDestinationContainer = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName; // Initialized successfully return(true); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } return(false); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount); var statisticsDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); var galleryDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceDatabase); var dataStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount); _sqlCommandTimeoutSeconds = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.CommandTimeOut) ?? DefaultSqlCommandTimeoutSeconds; _perPackageReportDegreeOfParallelism = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.PerPackageReportDegreeOfParallelism) ?? DefaultPerPackageReportDegreeOfParallelism; _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString, JobArgumentNames.AzureCdnCloudStorageAccount); _statisticsContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName), JobArgumentNames.AzureCdnCloudStorageContainerName); _dataStorageAccount = ValidateAzureCloudStorageAccount(dataStorageAccountConnectionString, JobArgumentNames.DataStorageAccount); _reportName = ValidateReportName(JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.WarehouseReportName)); _statisticsDatabase = new SqlConnectionStringBuilder(statisticsDatabaseConnectionString); _galleryDatabase = new SqlConnectionStringBuilder(galleryDatabaseConnectionString); var containerNames = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataContainerName) .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var containerName in containerNames) { ValidateAzureContainerName(containerName, JobArgumentNames.DataContainerName); } _dataContainerNames = containerNames; }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { Source = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceDatabase, EnvironmentVariableKeys.SqlGallery)); WarehouseConnection = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DestinationDatabase, EnvironmentVariableKeys.SqlWarehouse)); Destination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.WarehouseStorageAccount, EnvironmentVariableKeys.WarehouseStorage)); DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.WarehouseContainerName) ?? DefaultPackageStatsContainerName; DestinationContainer = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); _globalReportBuilders = new Dictionary <string, Func <Task> >(StringComparer.OrdinalIgnoreCase) { { NuGetClientVersion, () => CreateReport(NuGetClientVersion, "Scripts.DownloadReport_NuGetClientVersion.sql") }, { Last6Months, () => CreateReport(Last6Months, "Scripts.DownloadReport_Last6Months.sql") }, { RecentPopularity, () => CreateReport(RecentPopularity, "Scripts.DownloadReport_RecentPopularity.sql") }, { RecentPopularityDetail, () => CreateReport(RecentPopularityDetail, "Scripts.DownloadReport_RecentPopularityDetail.sql") }, }; return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { Source = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceDatabase, EnvironmentVariableKeys.SqlGallery)); OutputDirectory = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.OutputDirectory); if (string.IsNullOrEmpty(OutputDirectory)) { Destination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination, EnvironmentVariableKeys.StoragePrimary)); DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultContainerName; DestinationContainer = Destination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); } return(true); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)); Source = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source)); PrimaryDestination = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination)); var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination); SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr); SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName; DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName; SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName); PrimaryDestinationContainer = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName); CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName; }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase, EnvironmentVariableKeys.SqlGallery)); DataStorageAccount = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount, EnvironmentVariableKeys.StoragePrimary)); DataContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DataContainerName); if (string.IsNullOrEmpty(DataContainerName)) { DataContainerName = DefaultDataContainerName; } ContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.ContainerName); // Initialized successfully, return true return(true); }
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>(); if (!jobArgsDictionary.ContainsKey(JobArgumentNames.ScheduledTask)) { throw new NotSupportedException("The required argument -Task is missing."); } _jobArgsDictionary = jobArgsDictionary; } catch (Exception exception) { _logger.LogCritical(LogEvents.JobInitFailed, exception, "Failed to initialize job!"); return(false); } return(true); }
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); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString); _targetClientName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "TargetClientName"); _userAgentFilter = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "UserAgentFilter"); }
public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary) { var secretInjector = (ISecretInjector)serviceContainer.GetService(typeof(ISecretInjector)); var statisticsDbConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); _statisticsDbConnectionFactory = new AzureSqlConnectionFactory(statisticsDbConnectionString, secretInjector); _targetClientName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "TargetClientName"); _userAgentFilter = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "UserAgentFilter"); }
public AzureStorage(IDictionary <string, string> jobArgsDictionary) { Source = CloudStorageAccount.Parse(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceStorage)); SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultSourceContainerName; SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName); Backups = CloudStorageAccount.Parse(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.BackupStorage)); BackupsContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.BackupContainerName) ?? DefaultBackupContainerName; BackupsContainer = Backups.CreateCloudBlobClient().GetContainerReference(BackupsContainerName); SnapshotService = new AzureSnapshotService(); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { string heartbeatconfig = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.HeartbeatConfig); if (string.IsNullOrEmpty(heartbeatconfig)) { heartbeatconfig = DefaultConfig; } DashboardStorage = CloudStorageAccount.Parse( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DashboardStorageAccount, EnvironmentVariableKeys.StorageDashboard)); DashboardStorageContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DashboardStorageContainer) ?? DefaultDashboardContainerName; DashboardStorageContainer = DashboardStorage.CreateCloudBlobClient().GetContainerReference(DashboardStorageContainerName); LogFileSuffix = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LogFileSuffix); if (LogFileSuffix == null) { throw new InvalidOperationException("LogFileSuffix argument must be specified. EXAMPLE USAGE: -LogFileSuffix v2"); } // Read Config File and get values ReadConfigFile(heartbeatconfig); foreach (var jobName in JobsToMonitor.Keys) { LastCheckedForJob[jobName] = null; } foreach (var jobName in JobsToMonitor.Keys) { JobSucceeded[jobName] = false; } // Initialize Log File names VerboseLogFileName = GenerateLogFileName("ProcessRecyle_Verbose_"); ConciseLogFileName = GenerateLogFileName("ProcessRecyle_Concise_"); AlertLogFileName = GenerateLogFileName("ProcessRecyle_Alert_"); //Initialize Event Log AppEventLog = new EventLog(); AppEventLog.Log = "Application"; // Record process information foreach (var jobName in JobsToMonitor.Keys) { RecordProcessInformation(jobName, "START"); } return(true); }
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); }
private static bool Init(IDictionary <string, string> argsDictionary) { try { var databaseConnectionString = JobConfigurationManager.GetArgument(argsDictionary, JobArgumentNames.StatisticsDatabase); _targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString); _targetClientName = JobConfigurationManager.TryGetArgument(argsDictionary, "TargetClientName"); _userAgentFilter = JobConfigurationManager.TryGetArgument(argsDictionary, "UserAgentFilter"); return(true); } catch (Exception exception) { Trace.TraceError(exception.ToString()); } return(false); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase, EnvironmentVariableKeys.SqlGallery)); string retryCountString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.RetryCount); if (string.IsNullOrEmpty(retryCountString)) { RetryCount = DefaultRetryCount; } else { RetryCount = Convert.ToInt32(retryCountString); } LicenseReportService = new Uri(JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportService)); LicenseReportUser = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportUser); LicenseReportPassword = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportPassword); // Build credentials if (!string.IsNullOrEmpty(LicenseReportUser)) { if (!string.IsNullOrEmpty(LicenseReportPassword)) { LicenseReportCredentials = new NetworkCredential(LicenseReportUser, LicenseReportPassword); } else { LicenseReportCredentials = new NetworkCredential(LicenseReportUser, string.Empty); } } else if (!string.IsNullOrEmpty(LicenseReportPassword)) { LicenseReportCredentials = new NetworkCredential(string.Empty, LicenseReportPassword); } return(true); }
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); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); var loggerFactory = LoggingSetup.CreateLoggerFactory(); _logger = loggerFactory.CreateLogger <Job>(); var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount); var statisticsDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase); var galleryDatabaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.SourceDatabase); var dataStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount); _cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString, JobArgumentNames.AzureCdnCloudStorageAccount); _statisticsContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName), JobArgumentNames.AzureCdnCloudStorageContainerName); _dataStorageAccount = ValidateAzureCloudStorageAccount(dataStorageAccountConnectionString, JobArgumentNames.DataStorageAccount); _reportName = ValidateReportName(JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.WarehouseReportName)); _statisticsDatabase = new SqlConnectionStringBuilder(statisticsDatabaseConnectionString); _galleryDatabase = new SqlConnectionStringBuilder(galleryDatabaseConnectionString); var containerNames = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataContainerName) .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var containerName in containerNames) { ValidateAzureContainerName(containerName, JobArgumentNames.DataContainerName); } _dataContainerNames = containerNames; } catch (Exception exception) { _logger.LogError("Failed to initialize job! {Exception}", exception); return(false); } return(true); }
public override void Init(IDictionary <string, string> jobArgsDictionary) { _galleryBaseAddress = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.GalleryBaseAddress); var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount); _cloudStorageAccount = CreateCloudStorageAccount(JobArgumentNames.DataStorageAccount, storageConnectionString); _containerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName); _runValidationTasks = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.RunValidationTasks).Split(';'); _requestValidationTasks = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.RequestValidationTasks).Split(';'); _batchSize = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.BatchSize) ?? DefaultBatchSize; // Add validators if (_runValidationTasks.Contains(VcsValidator.ValidatorName)) { var serviceUrl = new Uri(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorServiceUrl)); var consumerCode = "DIRECT"; var callbackUrl = new Uri(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorCallbackUrl)); var packageUrlTemplate = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageUrlTemplate); var submitterAlias = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.VcsValidatorSubmitterAlias); // if contact alias set, use it, if not, use submitter alias. var contactAlias = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.VcsContactAlias) ?? submitterAlias; var scanningService = new VcsVirusScanningService( serviceUrl, consumerCode, contactAlias, submitterAlias, LoggerFactory); _validators.Add(new VcsValidator( callbackUrl, packageUrlTemplate, scanningService, LoggerFactory.CreateLogger <VcsValidator>())); } }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey); ApplicationInsights.Initialize(instrumentationKey); var loggerFactory = LoggingSetup.CreateLoggerFactory(); _logger = loggerFactory.CreateLogger <Job>(); var retrievedMaxManifestSize = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MaxManifestSize); MaxManifestSize = retrievedMaxManifestSize == null ? DefaultMaxAllowedManifestBytes : Convert.ToInt64(retrievedMaxManifestSize); PackageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)); Enum.TryParse(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StorageType), out StorageType storageType); switch (storageType) { case StorageType.FileSystem: FileStorage = new FileSystemStorage(jobArgsDictionary); break; default: FileStorage = new AzureStorage(jobArgsDictionary); break; } MaxTryCount = DefaultMaxRetryCount; } catch (Exception exception) { Trace.TraceError($"Failed to initalize job! {exception}"); return(false); } return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { _packageDatabase = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase)); var retryCountString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.RetryCount); if (string.IsNullOrEmpty(retryCountString)) { _retryCount = _defaultRetryCount; } else { _retryCount = Convert.ToInt32(retryCountString); } _licenseReportService = new Uri(JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportService)); _licenseReportUser = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportUser); _licenseReportPassword = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.LicenseReportPassword); // Build credentials if (!string.IsNullOrEmpty(_licenseReportUser)) { if (!string.IsNullOrEmpty(_licenseReportPassword)) { _licenseReportCredentials = new NetworkCredential(_licenseReportUser, _licenseReportPassword); } else { _licenseReportCredentials = new NetworkCredential(_licenseReportUser, string.Empty); } } else if (!string.IsNullOrEmpty(_licenseReportPassword)) { _licenseReportCredentials = new NetworkCredential(string.Empty, _licenseReportPassword); } return(true); }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { WarehouseConnection = new SqlConnectionStringBuilder( JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DestinationDatabase, EnvironmentVariableKeys.SqlWarehouse)); string commandTimeOutString = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CommandTimeOut); if (string.IsNullOrEmpty(commandTimeOutString)) { CommandTimeOut = 0; } else { int cmdTimeout = Convert.ToInt32(commandTimeOutString); CommandTimeOut = cmdTimeout > 0 ? cmdTimeout : 0; } return(true); }