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); }
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); }
public static TsiDataClient AadLoginAsApplication(AzureUtils.ApplicationClientInfo applicationClientInfo) { return(new TsiDataClient(() => AzureUtils.AadLoginAsApplicationAsync("https://api.timeseries.azure.com/", applicationClientInfo))); }