コード例 #1
0
        public void MapMapEqual()
        {
            var from = new FeatureEntryTableEntity
            {
                AllowedIPs    = "42.42.0.0/16,33.33.33.33",
                Countries     = "EN,US",
                Description   = "Test",
                Disabled      = "True",
                Timestamp     = DateTimeOffset.UtcNow,
                Issuer        = 42,
                ReleaseDate   = DateTimeOffset.Now,
                RowKey        = "SomeName",
                RequiredRoles = "Tester,CSV",
                Users         = "13,123",
                PartitionKey  = FeatureGateStore.GatePartitionKey,
                Continents    = "Afrika"
            };
            var toFrom = from.To <FeatureEntry>().To <FeatureEntryTableEntity>();

            DeepAssert.Equal(from, toFrom);
        }
コード例 #2
0
        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);
            }
        }