示例#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);
        }
示例#2
0
        public static async Task <CloudTable> GetOrCreateTableAsync(AzureUtils.StorageAccountInfo storageAcountInfo, string tableName)
        {
            var storageCredentials            = new StorageCredentials(storageAcountInfo.StorageAccountName, storageAcountInfo.StorageAccountKey);
            var cloudStorageAccount           = new CloudStorageAccount(storageCredentials, useHttps: true);
            CloudTableClient cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            CloudTable       cloudTable       = cloudTableClient.GetTableReference(tableName);

            if (await cloudTable.CreateIfNotExistsAsync())
            {
                Logger.TraceLine($"Cloud table '{cloudTable.Name}' created.");
            }
            else
            {
                Logger.TraceLine($"Cloud table '{cloudTable.Name}' already exists.");
            }

            return(cloudTable);
        }