public async Task SqlContainerCreateAndUpdate()
        {
            var container = await CreateSqlContainer(null);

            Assert.AreEqual(_containerName, container.Data.Resource.Id);
            // Seems bug in swagger definition
            //Assert.AreEqual(TestThroughput1, container.Data.Options.Throughput);

            bool ifExists = await SqlContainerCollection.ExistsAsync(_containerName);

            Assert.True(ifExists);

            // NOT WORKING API
            //ThroughputSettingsData throughtput = await container.GetMongoDBCollectionThroughputAsync();
            SqlContainerResource container2 = await SqlContainerCollection.GetAsync(_containerName);

            Assert.AreEqual(_containerName, container2.Data.Resource.Id);
            //Assert.AreEqual(TestThroughput1, container2.Data.Options.Throughput);

            VerifySqlContainers(container, container2);

            // TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590
            var updateOptions = new SqlContainerCreateOrUpdateContent(AzureLocation.WestUS, container.Data.Resource)
            {
                Options = new CreateUpdateOptions {
                    Throughput = TestThroughput2
                }
            };

            container = (await SqlContainerCollection.CreateOrUpdateAsync(WaitUntil.Completed, _containerName, updateOptions)).Value;
            Assert.AreEqual(_containerName, container.Data.Resource.Id);
            container2 = await SqlContainerCollection.GetAsync(_containerName);

            VerifySqlContainers(container, container2);
        }
        public async Task SqlContainerRetrieveContinuousBackupInformation()
        {
            var container = await CreateSqlContainer(null);

            BackupInformation backupInfo = (await container.RetrieveContinuousBackupInformationAsync(WaitUntil.Completed, new ContinuousBackupRestoreLocation {
                Location = AzureLocation.WestUS
            })).Value;
            long restoreTime             = DateTimeOffset.Parse(backupInfo.ContinuousBackupInformation.LatestRestorableTimestamp).ToUnixTimeMilliseconds();

            Assert.True(restoreTime > 0);

            var updateOptions = new SqlContainerCreateOrUpdateContent(container.Id, _containerName, container.Data.ResourceType, null,
                                                                      new Dictionary <string, string>(),// TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590
                                                                      AzureLocation.WestUS, container.Data.Resource, new CreateUpdateOptions {
                Throughput = TestThroughput2
            });

            container  = (await SqlContainerCollection.CreateOrUpdateAsync(WaitUntil.Completed, _containerName, updateOptions)).Value;
            backupInfo = (await container.RetrieveContinuousBackupInformationAsync(WaitUntil.Completed, new ContinuousBackupRestoreLocation {
                Location = AzureLocation.WestUS
            })).Value;
            long latestRestoreTime = DateTimeOffset.Parse(backupInfo.ContinuousBackupInformation.LatestRestorableTimestamp).ToUnixTimeMilliseconds();

            Assert.True(latestRestoreTime > 0);
            Assert.True(latestRestoreTime > restoreTime);
        }
        internal static async Task <SqlContainerResource> CreateSqlContainer(string name, AutoscaleSettings autoscale, SqlContainerCollection sqlContainerCollection)
        {
            var sqlDatabaseCreateUpdateOptions = new SqlContainerCreateOrUpdateContent(AzureLocation.WestUS,
                                                                                       new Models.SqlContainerResource(name)
            {
                PartitionKey = new ContainerPartitionKey(new List <string> {
                    "/address/zipCode"
                }, null, null, false)
                {
                    Kind = new PartitionKind("Hash")
                },
                IndexingPolicy = new IndexingPolicy(
                    true,
                    IndexingMode.Consistent,
                    new List <IncludedPath>
                {
                    new IncludedPath {
                        Path = "/*"
                    }
                },
                    new List <ExcludedPath>
                {
                    new ExcludedPath {
                        Path = "/pathToNotIndex/*"
                    }
                },
                    new List <IList <CompositePath> >
                {
                    new List <CompositePath>
                    {
                        new CompositePath {
                            Path = "/orderByPath1", Order = CompositePathSortOrder.Ascending
                        },
                        new CompositePath {
                            Path = "/orderByPath2", Order = CompositePathSortOrder.Descending
                        }
                    }
                },
                    new List <SpatialSpec>
                {
                    new SpatialSpec
                    (
                        "/*",
                        new List <SpatialType>
                    {
                        new SpatialType("Point")
                    }
                    ),
                }
                    )
            })
            {
                Options = BuildDatabaseCreateUpdateOptions(TestThroughput1, autoscale),
            };
            var sqlContainerLro = await sqlContainerCollection.CreateOrUpdateAsync(WaitUntil.Completed, name, sqlDatabaseCreateUpdateOptions);

            return(sqlContainerLro.Value);
        }
        public virtual async Task <ArmOperation <SqlContainerResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string containerName, SqlContainerCreateOrUpdateContent content, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(containerName, nameof(containerName));
            Argument.AssertNotNull(content, nameof(content));

            using var scope = _sqlContainerSqlResourcesClientDiagnostics.CreateScope("SqlContainerCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _sqlContainerSqlResourcesRestClient.CreateUpdateSqlContainerAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, containerName, content, cancellationToken).ConfigureAwait(false);

                var operation = new CosmosDBArmOperation <SqlContainerResource>(new SqlContainerOperationSource(Client), _sqlContainerSqlResourcesClientDiagnostics, Pipeline, _sqlContainerSqlResourcesRestClient.CreateCreateUpdateSqlContainerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, containerName, content).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }