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 void InitializeJobConfiguration(IServiceProvider serviceProvider) { _configuration = serviceProvider.GetRequiredService <IOptionsSnapshot <CollectAzureCdnLogsConfiguration> >().Value; if (string.IsNullOrEmpty(_configuration.AzureCdnAccountNumber)) { throw new ArgumentException("Configuration 'AzureCdnAccountNumber' is required", nameof(_configuration)); } if (string.IsNullOrEmpty(_configuration.AzureCdnCloudStorageContainerName)) { throw new ArgumentException("Configuration 'AzureCdnCloudStorageContainerName' is required", nameof(_configuration)); } if (string.IsNullOrEmpty(_configuration.FtpSourceUsername)) { throw new ArgumentException("Configuration 'FtpSourceUsername' is required", nameof(_configuration)); } if (string.IsNullOrEmpty(_configuration.FtpSourcePassword)) { throw new ArgumentException("Configuration 'FtpSourcePassword' is required", nameof(_configuration)); } _cloudStorageAccount = ValidateAzureCloudStorageAccount(_configuration.AzureCdnCloudStorageAccount); _azureCdnPlatform = ValidateAzureCdnPlatform(_configuration.AzureCdnPlatform); _ftpServerUri = ValidateFtpUri(_configuration.FtpSourceUri); }
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 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); }
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(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary) { 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); }
public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary) { base.Init(serviceContainer, jobArgsDictionary); _configuration = _serviceProvider.GetRequiredService <IOptionsSnapshot <ImportAzureCdnStatisticsConfiguration> >().Value; _azureCdnPlatform = ValidateAzureCdnPlatform(_configuration.AzureCdnPlatform); var cloudStorageAccount = ValidateAzureCloudStorageAccount(_configuration.AzureCdnCloudStorageAccount); _cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); _cloudBlobClient.DefaultRequestOptions.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(10), 5); _blobLeaseManager = new LogFileProvider( _cloudBlobClient.GetContainerReference(_configuration.AzureCdnCloudStorageContainerName), LoggerFactory); }
public static string GetRawLogFilePrefix(this AzureCdnPlatform platform) { switch (platform) { case AzureCdnPlatform.HttpLargeObject: return(_largeHttpObjectPrefix); case AzureCdnPlatform.HttpSmallObject: return(_smallHttpObjectPrefix); case AzureCdnPlatform.ApplicationDeliveryNetwork: return(_applicationDeliveryNetworkPrefix); case AzureCdnPlatform.FlashMediaStreaming: return(_flashMediaStreamingPrefix); default: throw new ArgumentOutOfRangeException("platform", platform, null); } }
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 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); return true; } catch (Exception ex) { Trace.TraceError(ex.ToString()); } return false; }
public override bool Init(IDictionary <string, string> jobArgsDictionary) { try { 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); return(true); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } return(false); }
internal void CanGetRawLogFilePrefixForValidAzureCdnPlatforms(AzureCdnPlatform platform, string prefix) { var actual = AzureCdnPlatformExtensions.GetRawLogFilePrefix(platform); Assert.Equal(prefix, actual); }
internal void CanParseValidAzureCdnPlatformStrings(string prefix, AzureCdnPlatform platform) { var actual = AzureCdnPlatformExtensions.ParseAzureCdnPlatformPrefix(prefix); Assert.Equal(platform, actual); }
internal void CanGetRawLogFilePrefixForValidAzureCdnPlatforms(AzureCdnPlatform platform, string prefix) { var actual = AzureCdnPlatformExtensions.GetRawLogFilePrefix(platform); Assert.Equal(prefix, actual); }
internal void CanParseValidAzureCdnPlatformStrings(string prefix, AzureCdnPlatform platform) { var actual = AzureCdnPlatformExtensions.ParseAzureCdnPlatformPrefix(prefix); Assert.Equal(platform, actual); }