public override async Task <CosmosContainerResponse> CreateContainerIfNotExistsAsync(
            CosmosContainerSettings containerSettings,
            int?throughput = null,
            CosmosRequestOptions requestOptions = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (containerSettings == null)
            {
                throw new ArgumentNullException(nameof(containerSettings));
            }

            this.ValidateContainerSettings(containerSettings);

            CosmosContainer         cosmosContainer         = this[containerSettings.Id];
            CosmosContainerResponse cosmosContainerResponse = await cosmosContainer.ReadAsync(cancellationToken : cancellationToken);

            if (cosmosContainerResponse.StatusCode != HttpStatusCode.NotFound)
            {
                return(cosmosContainerResponse);
            }

            cosmosContainerResponse = await this.CreateContainerAsync(containerSettings, throughput, requestOptions, cancellationToken : cancellationToken);

            if (cosmosContainerResponse.StatusCode != HttpStatusCode.Conflict)
            {
                return(cosmosContainerResponse);
            }

            // This second Read is to handle the race condition when 2 or more threads have Read the database and only one succeeds with Create
            // so for the remaining ones we should do a Read instead of throwing Conflict exception
            return(await cosmosContainer.ReadAsync(cancellationToken : cancellationToken));
        }
 internal CosmosContainerResponse CreateContainerResponse(
     CosmosResponseMessage cosmosResponseMessage,
     CosmosContainer container)
 {
     return(CosmosContainerResponse.CreateResponse(
                cosmosResponseMessage,
                this.jsonSerializer,
                container));
 }