Beispiel #1
0
        public MainProcessor(
            AzureUtils.ApplicationClientInfo applicationClientInfo,
            AzureUtils.StorageAccountInfo storageAccountInfo,
            string tsidCheckpointingTableName,
            string stationObservationsCheckpointingPartitionKey,
            string eventHubConnectionString,
            string azureMapsSubscriptionKey,
            string azureMapsCacheTableName,
            string tsiEnvironmentFqdn)
        {
            _noaaClient = new NoaaClient();

            _stationsProcessor = new StastionsProcessor(
                _noaaClient,
                TsiDataClient.AadLoginAsApplication(applicationClientInfo),
                tsiEnvironmentFqdn,
                new AzureMapsClient(
                    azureMapsSubscriptionKey,
                    AzureUtils.GetOrCreateTableAsync(storageAccountInfo, azureMapsCacheTableName).Result));

            _stationObservationsCheckpointing = new TsidCheckpointing(
                AzureUtils.GetOrCreateTableAsync(storageAccountInfo, tsidCheckpointingTableName).Result,
                stationObservationsCheckpointingPartitionKey);

            _stationObservationProcessors = new Dictionary <string, StationObservationsProcessor>();

            _eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString);
        }
Beispiel #2
0
        public static async Task <string> AadLoginAsApplicationAsync(string resource, AzureUtils.ApplicationClientInfo applicationClientInfo)
        {
            var authenticationContext =
                new AuthenticationContext($"https://login.windows.net/{applicationClientInfo.DirectoryId}", TokenCache.DefaultShared);

            AuthenticationResult token = await authenticationContext.AcquireTokenAsync(
                resource,
                new ClientCredential(applicationClientInfo.ClientId, applicationClientInfo.ClientSecret));

            return(token.AccessToken);
        }
Beispiel #3
0
 public static TsiDataClient AadLoginAsApplication(AzureUtils.ApplicationClientInfo applicationClientInfo)
 {
     return(new TsiDataClient(() => AzureUtils.AadLoginAsApplicationAsync("https://api.timeseries.azure.com/", applicationClientInfo)));
 }