Example #1
0
 private ExecutionContext(
     CosmosGateway gateway,
     Uri configUrl,
     string[] destructiveFlags,
     Database database) : this(gateway, configUrl, destructiveFlags)
 {
     Database = database ?? throw new ArgumentNullException(nameof(database));
 }
Example #2
0
 private ExecutionContext(
     CosmosGateway gateway,
     Uri configUrl,
     string[] destructiveFlags,
     Database database,
     DocumentCollection collection) : this(gateway, configUrl, destructiveFlags, database)
 {
     Collection = collection ?? throw new ArgumentNullException(nameof(collection));
 }
Example #3
0
        static void Main(string[] args)
        {
            var accountEndpointText = Environment.GetEnvironmentVariable("ACCOUNT_ENDPOINT");
            var key       = Environment.GetEnvironmentVariable("ACCOUNT_KEY");
            var targetUrl = Environment.GetEnvironmentVariable("TARGET_URL");

            Console.WriteLine($"Account Endpoint:  {accountEndpointText}");
            Console.WriteLine($"Account Key:  {key}");
            Console.WriteLine($"Target URL:  {targetUrl}");
            Console.WriteLine();

            if (string.IsNullOrWhiteSpace(accountEndpointText))
            {
                Console.WriteLine("Environment Variable ACCOUNT_ENDPOINT missing");

                return;
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                Console.WriteLine("Environment Variable ACCOUNT_KEY missing");

                return;
            }
            if (string.IsNullOrWhiteSpace(targetUrl))
            {
                Console.WriteLine("Environment Variable TARGET_URL missing");

                return;
            }

            var accountEndpoint = new Uri(accountEndpointText);

            Console.WriteLine("Target Content:");

            var gateway       = new CosmosGateway(accountEndpoint, key);
            var targetUri     = new Uri(targetUrl);
            var targetContent = ContentHelper.GetContentAsync(targetUri).Result;

            Console.WriteLine();
            Console.WriteLine(targetContent);
            Console.WriteLine();

            var account = JsonConvert.DeserializeObject <AccountModel>(targetContent);
            var context = new ExecutionContext(
                gateway,
                targetUri,
                account.DestructiveFlags);

            account.ConvergeTargetAsync(context).Wait();
            Console.WriteLine();
            Console.WriteLine("Successfully apply configuration");
        }
Example #4
0
 public ExecutionContext(CosmosGateway gateway, Uri configUrl, string[] destructiveFlags)
 {
     Gateway           = gateway ?? throw new ArgumentNullException(nameof(gateway));
     ConfigUrl         = configUrl ?? throw new ArgumentNullException(nameof(configUrl));
     _destructiveFlags = destructiveFlags ?? new string[0];
 }