public GeoLocationService(IConfiguration configuration, ILogger <GeoLocationQuery> logger, IHttpClientFactory httpClientFactory, EventualCloudTableClient cache) { logger_ = logger; apiKey_ = configuration.GetValue <string>("IPDATA-API-KEY"); ipdata_ = new IpDataClient(apiKey_); cacheTimeout_ = TimeSpan.FromDays(configuration.GetValue <byte>("IPDATA-CACHE-TIMEOUT-DAYS", 3)); httpClientFactory_ = httpClientFactory; var slotName = configuration.GetDeploymentSlot().ToString().ToLower(); ipCacheTable_ = cache.GetTableReference($"{slotName}IpCache"); ipCacheTable_.CreateIfNotExists();// making it on par with old storage based GeoLocationQuery (create table in ctor) }
public FeatureGateStore( IConfiguration configuration, ILogger <FeatureGateStore> logger, ServiceOption serviceOption, EventualCloudTableClient storage) { var slot = configuration.GetDeploymentSlot().ToString().ToLower(); var slotName = slot.ToString().ToLower(); var connection = configuration.GetValue <string>("SAFeatureGate"); newGates_ = configuration.GetValue("NewFeatureGates", false); var storageAccount = CloudStorageAccount.Parse(connection); var tableClient = TableStorageHelpers.CreateClient(storageAccount); Storage = storage.GetTableReference($"{slotName}Gates"); Storage.CreateIfNotExists(); logger_ = logger; rnd_ = new Random(); GatesTable = new TableStorage(tableClient, $"{slotName}Gates", true); Service = serviceOption.Service; }
public async Task MigrateFeatureGatesToCosmos( [FromServices] EventualCloudTableClient storage, [FromServices] IConfiguration configuration, [FromServices] ServiceOption serviceOption) { // data is small and not online, so next tech is ok for this // also it is out of azcontext code, so just do it here var slot = configuration.GetDeploymentSlot().ToString().ToLower(); var slotName = slot.ToString().ToLower(); var connection = configuration.GetValue <string>("SAFeatureGate"); var storageAccount = CloudStorageAccount.Parse(connection); var tableClient = TableStorageHelpers.CreateClient(storageAccount); var newTable = storage.GetTableReference($"{slotName}Gates"); await newTable.CreateIfNotExistsAsync(); var gatesTable = new TableStorage(tableClient, $"{slotName}Gates", true); var data = await gatesTable.ExecuteQueryAsync(new TableQuery <LegacyFeatureEntry>()); foreach (var item in data) { var newEntry = new FeatureEntryTableEntity { AllowedIPs = item.AZAllowedIPs, Continents = item.AZContinents, Countries = item.AZCountries, Description = item.Description, Disabled = item.Disabled.ToString(), PartitionKey = item.PartitionKey, Issuer = item.Issuer, ReleaseDate = item.ReleaseDate, RequiredRoles = item.AZRequiredRoles, RowKey = item.RowKey, Users = item.AZUsers, }; await newTable.InsertOrMergeAsync(newEntry); } }