private async Task ContainerOperations(CosmosDatabase database, bool dbNotExist) { // Create should fail if the database does not exist if (dbNotExist) { CosmosContainerSettings newcontainerSettings = new CosmosContainerSettings(id: DoesNotExist, partitionKeyPath: "/pk"); this.VerifyNotFoundResponse(await database.CreateContainerStreamAsync(newcontainerSettings, requestUnits: 500)); } CosmosContainer doesNotExistContainer = database.GetContainer(DoesNotExist); this.VerifyNotFoundResponse(await doesNotExistContainer.ReadStreamAsync()); CosmosContainerSettings containerSettings = new CosmosContainerSettings(id: DoesNotExist, partitionKeyPath: "/pk"); this.VerifyNotFoundResponse(await doesNotExistContainer.ReplaceStreamAsync(containerSettings)); this.VerifyNotFoundResponse(await doesNotExistContainer.DeleteStreamAsync()); // Validate Child resources await this.ItemOperations(doesNotExistContainer, true); // The database exists create a container and validate it's children if (!dbNotExist) { CosmosContainer containerExists = await database.CreateContainerAsync( id : "NotFoundTest" + Guid.NewGuid().ToString(), partitionKeyPath : "/pk"); await this.ItemOperations(containerExists, false); } }