private static CosmosClient GetClient() { (string endpoint, string authKey) = TestCommon.GetAccountInfo(); return(new CosmosClientBuilder(endpoint, authKey) .WithEncryptionKeyWrapProvider(new TestKeyWrapProvider()) .Build()); }
private static CosmosClient GetClient(Encryptor encryptor) { (string endpoint, string authKey) = TestCommon.GetAccountInfo(); return(new CosmosClientBuilder(endpoint, authKey) .WithEncryptor(encryptor) .Build()); }
public async Task EncryptionResourceTokenAuth() { User user = EncryptionTests.databaseCore.GetUser(Guid.NewGuid().ToString()); await EncryptionTests.databaseCore.CreateUserAsync(user.Id); PermissionProperties permission = await user.CreatePermissionAsync( new PermissionProperties(Guid.NewGuid().ToString(), PermissionMode.All, EncryptionTests.container)); TestDoc testDoc = await EncryptionTests.CreateItemAsync(EncryptionTests.containerCore, EncryptionTests.dekId, TestDoc.PathsToEncrypt); (string endpoint, string _) = TestCommon.GetAccountInfo(); CosmosClient resourceTokenBasedClient = new CosmosClientBuilder(endpoint, permission.Token) .WithEncryptionKeyWrapProvider(new TestKeyWrapProvider()) .Build(); DatabaseCore databaseForTokenClient = (DatabaseInlineCore)resourceTokenBasedClient.GetDatabase(EncryptionTests.databaseCore.Id); Container containerForTokenClient = databaseForTokenClient.GetContainer(EncryptionTests.container.Id); await EncryptionTests.PerformForbiddenOperationAsync(() => databaseForTokenClient.GetDataEncryptionKey(EncryptionTests.dekId).ReadAsync(), "DEK.ReadAsync"); await EncryptionTests.PerformForbiddenOperationAsync(() => containerForTokenClient.ReadItemAsync <TestDoc>(testDoc.Id, new PartitionKey(testDoc.PK)), "ReadItemAsync"); await EncryptionTests.PerformForbiddenOperationAsync(() => containerForTokenClient.ReadItemStreamAsync(testDoc.Id, new PartitionKey(testDoc.PK)), "ReadItemStreamAsync"); }
public async Task EncryptionBulkCrud() { TestDoc docToReplace = await EncryptionTests.CreateItemAsync(EncryptionTests.containerCore, EncryptionTests.dekId, TestDoc.PathsToEncrypt); docToReplace.NonSensitive = Guid.NewGuid().ToString(); docToReplace.Sensitive = Guid.NewGuid().ToString(); TestDoc docToUpsert = await EncryptionTests.CreateItemAsync(EncryptionTests.containerCore, EncryptionTests.dekId, TestDoc.PathsToEncrypt); docToUpsert.NonSensitive = Guid.NewGuid().ToString(); docToUpsert.Sensitive = Guid.NewGuid().ToString(); TestDoc docToDelete = await EncryptionTests.CreateItemAsync(EncryptionTests.containerCore, EncryptionTests.dekId, TestDoc.PathsToEncrypt); (string endpoint, string authKey) = TestCommon.GetAccountInfo(); CosmosClient clientWithBulk = new CosmosClientBuilder(endpoint, authKey) .WithEncryptionKeyWrapProvider(new TestKeyWrapProvider()) .WithBulkExecution(true) .Build(); DatabaseCore databaseWithBulk = (DatabaseInlineCore)clientWithBulk.GetDatabase(EncryptionTests.databaseCore.Id); ContainerCore containerWithBulk = (ContainerInlineCore)databaseWithBulk.GetContainer(EncryptionTests.container.Id); List <Task> tasks = new List <Task>(); tasks.Add(EncryptionTests.CreateItemAsync(containerWithBulk, EncryptionTests.dekId, TestDoc.PathsToEncrypt)); tasks.Add(EncryptionTests.UpsertItemAsync(containerWithBulk, TestDoc.Create(), EncryptionTests.dekId, TestDoc.PathsToEncrypt, HttpStatusCode.Created)); tasks.Add(EncryptionTests.ReplaceItemAsync(containerWithBulk, docToReplace, EncryptionTests.dekId, TestDoc.PathsToEncrypt)); tasks.Add(EncryptionTests.UpsertItemAsync(containerWithBulk, docToUpsert, EncryptionTests.dekId, TestDoc.PathsToEncrypt, HttpStatusCode.OK)); tasks.Add(EncryptionTests.DeleteItemAsync(containerWithBulk, docToDelete)); await Task.WhenAll(tasks); }
public async Task CreateAndInitializeWithCosmosClientBuilderTest() { int httpCallsMade = 0; HttpClientHandlerHelper httpClientHandlerHelper = new HttpClientHandlerHelper { RequestCallBack = (request, cancellationToken) => { httpCallsMade++; return(null); } }; (string endpoint, string authKey) = TestCommon.GetAccountInfo(); List <(string, string)> containers = new List <(string, string)> { ("ClientCreateAndInitializeDatabase", "ClientCreateAndInitializeContainer") }; CosmosClientBuilder builder = new CosmosClientBuilder(endpoint, authKey).WithHttpClientFactory(() => new HttpClient(httpClientHandlerHelper)); CosmosClient cosmosClient = await builder.BuildAndInitializeAsync(containers); Assert.IsNotNull(cosmosClient); int httpCallsMadeAfterCreation = httpCallsMade; ContainerInternal container = (ContainerInternal)cosmosClient.GetContainer("ClientCreateAndInitializeDatabase", "ClientCreateAndInitializeContainer"); ItemResponse <ToDoActivity> readResponse = await container.ReadItemAsync <ToDoActivity>("1", new Cosmos.PartitionKey("Status1")); Assert.AreEqual(httpCallsMade, httpCallsMadeAfterCreation); cosmosClient.Dispose(); }
public async Task EncryptionResourceTokenAuthRestricted() { TestDoc testDoc = await EncryptionTests.CreateItemAsync(EncryptionTests.itemContainerCore, EncryptionTests.dekId, TestDoc.PathsToEncrypt); User restrictedUser = EncryptionTests.databaseCore.GetUser(Guid.NewGuid().ToString()); await EncryptionTests.databaseCore.CreateUserAsync(restrictedUser.Id); PermissionProperties restrictedUserPermission = await restrictedUser.CreatePermissionAsync( new PermissionProperties(Guid.NewGuid().ToString(), PermissionMode.All, EncryptionTests.itemContainer)); CosmosDataEncryptionKeyProvider dekProvider = new CosmosDataEncryptionKeyProvider(new TestKeyWrapProvider()); TestEncryptor encryptor = new TestEncryptor(dekProvider); (string endpoint, string _) = TestCommon.GetAccountInfo(); CosmosClient clientForRestrictedUser = new CosmosClientBuilder(endpoint, restrictedUserPermission.Token) .WithEncryptor(encryptor) .Build(); Database databaseForRestrictedUser = clientForRestrictedUser.GetDatabase(EncryptionTests.databaseCore.Id); Container containerForRestrictedUser = databaseForRestrictedUser.GetContainer(EncryptionTests.itemContainer.Id); await EncryptionTests.PerformForbiddenOperationAsync(() => dekProvider.InitializeAsync(databaseForRestrictedUser, EncryptionTests.keyContainer.Id), "CosmosDekProvider.InitializeAsync"); await EncryptionTests.PerformOperationOnUninitializedDekProviderAsync(() => dekProvider.DataEncryptionKeyContainer.ReadDataEncryptionKeyAsync(EncryptionTests.dekId), "DEK.ReadAsync"); await EncryptionTests.PerformOperationOnUninitializedDekProviderAsync(() => containerForRestrictedUser.ReadItemAsync <TestDoc>(testDoc.Id, new PartitionKey(testDoc.PK)), "ReadItemAsync"); await EncryptionTests.PerformOperationOnUninitializedDekProviderAsync(() => containerForRestrictedUser.ReadItemStreamAsync(testDoc.Id, new PartitionKey(testDoc.PK)), "ReadItemStreamAsync"); }
internal static async Task CreateItemInNonPartitionedContainer( ContainerCore container, string itemId) { (string endpoint, string authKey)accountInfo = TestCommon.GetAccountInfo(); //Creating non partition Container item. HttpClient client = new System.Net.Http.HttpClient(); Uri baseUri = new Uri(accountInfo.endpoint); string dateTimeUtc = NonPartitionedContainerHelper.GetUtcDateTime(); string verb = "POST"; string resourceType = "docs"; string resourceLink = string.Format("dbs/{0}/colls/{1}/docs", container.Database.Id, container.Id); string authHeader = NonPartitionedContainerHelper.GenerateMasterKeyAuthorizationSignature( verb, container.LinkUri.OriginalString, resourceType, accountInfo.authKey, "master", "1.0", dateTimeUtc); client.DefaultRequestHeaders.Add("x-ms-date", dateTimeUtc); client.DefaultRequestHeaders.Add("x-ms-version", NonPartitionedContainerHelper.PreNonPartitionedMigrationApiVersion); client.DefaultRequestHeaders.Add("authorization", authHeader); string itemDefinition = JsonConvert.SerializeObject(ToDoActivity.CreateRandomToDoActivity(id: itemId)); { StringContent itemContent = new StringContent(itemDefinition); Uri requestUri = new Uri(baseUri, resourceLink); HttpResponseMessage response = await client.PostAsync(requestUri.ToString(), itemContent); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.ToString()); } }
internal static async Task CreateUndefinedPartitionItem( ContainerCore container, string itemId) { (string endpoint, string authKey)accountInfo = TestCommon.GetAccountInfo(); //Creating undefined partition key item, rest api used instead of .NET SDK api as it is not supported anymore. HttpClient client = new System.Net.Http.HttpClient(); Uri baseUri = new Uri(accountInfo.endpoint); client.DefaultRequestHeaders.Add("x-ms-date", utc_date); client.DefaultRequestHeaders.Add("x-ms-version", NonPartitionedContainerHelper.PreNonPartitionedMigrationApiVersion); client.DefaultRequestHeaders.Add("x-ms-documentdb-partitionkey", "[{}]"); //Creating undefined partition Container item. string verb = "POST"; string resourceType = "docs"; string resourceId = container.LinkUri.OriginalString; string resourceLink = string.Format("dbs/{0}/colls/{1}/docs", container.Database.Id, container.Id); string authHeader = NonPartitionedContainerHelper.GenerateMasterKeyAuthorizationSignature( verb, resourceId, resourceType, accountInfo.authKey, "master", "1.0"); client.DefaultRequestHeaders.Remove("authorization"); client.DefaultRequestHeaders.Add("authorization", authHeader); var payload = new { id = itemId, user = itemId }; string itemDefinition = JsonConvert.SerializeObject(payload); StringContent itemContent = new StringContent(itemDefinition); Uri requestUri = new Uri(baseUri, resourceLink); await client.PostAsync(requestUri.ToString(), itemContent); }
public async Task AadMockTest() { string databaseId = Guid.NewGuid().ToString(); string containerId = Guid.NewGuid().ToString(); using (CosmosClient cosmosClient = TestCommon.CreateCosmosClient()) { Database database = await cosmosClient.CreateDatabaseAsync(databaseId); Container container = await database.CreateContainerAsync( containerId, "/id"); } (string endpoint, string authKey) = TestCommon.GetAccountInfo(); LocalEmulatorTokenCredential simpleEmulatorTokenCredential = new LocalEmulatorTokenCredential(authKey); CosmosClientOptions clientOptions = new CosmosClientOptions() { ConnectionMode = ConnectionMode.Gateway, ConnectionProtocol = Protocol.Https }; using CosmosClient aadClient = new CosmosClient( endpoint, simpleEmulatorTokenCredential, clientOptions); TokenCredentialCache tokenCredentialCache = ((AuthorizationTokenProviderTokenCredential)aadClient.AuthorizationTokenProvider).tokenCredentialCache; // The refresh interval changes slightly based on how fast machine calculate the interval based on the expire time. Assert.IsTrue(15 <= tokenCredentialCache.BackgroundTokenCredentialRefreshInterval.Value.TotalMinutes, "Default background refresh should be 25% of the token life which is defaulted to 1hr"); Assert.IsTrue(tokenCredentialCache.BackgroundTokenCredentialRefreshInterval.Value.TotalMinutes > 14.7, "Default background refresh should be 25% of the token life which is defaulted to 1hr"); Database aadDatabase = await aadClient.GetDatabase(databaseId).ReadAsync(); Container aadContainer = await aadDatabase.GetContainer(containerId).ReadContainerAsync(); ToDoActivity toDoActivity = ToDoActivity.CreateRandomToDoActivity(); ItemResponse <ToDoActivity> itemResponse = await aadContainer.CreateItemAsync( toDoActivity, new PartitionKey(toDoActivity.id)); toDoActivity.cost = 42.42; await aadContainer.ReplaceItemAsync( toDoActivity, toDoActivity.id, new PartitionKey(toDoActivity.id)); await aadContainer.ReadItemAsync <ToDoActivity>( toDoActivity.id, new PartitionKey(toDoActivity.id)); await aadContainer.UpsertItemAsync(toDoActivity); await aadContainer.DeleteItemAsync <ToDoActivity>( toDoActivity.id, new PartitionKey(toDoActivity.id)); }
public async Task AuthIncorrectTest() { List <(string databaseId, string containerId)> containers = new List <(string databaseId, string containerId)> { ("ClientCreateAndInitializeDatabase", "ClientCreateAndInitializeContainer") }; string authKey = TestCommon.GetAccountInfo().authKey; CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync("https://127.0.0.1:0000/", authKey, containers); cosmosClient.Dispose(); }
public async Task AadMockNegativeRefreshRetryTest() { int getAadTokenCount = 0; string errorMessage = "Test Failure" + Guid.NewGuid(); void GetAadTokenCallBack( TokenRequestContext context, CancellationToken token) { getAadTokenCount++; throw new RequestFailedException( 408, errorMessage); } (string endpoint, string authKey) = TestCommon.GetAccountInfo(); LocalEmulatorTokenCredential simpleEmulatorTokenCredential = new LocalEmulatorTokenCredential( authKey, GetAadTokenCallBack); CosmosClientOptions clientOptions = new CosmosClientOptions() { TokenCredentialBackgroundRefreshInterval = TimeSpan.FromSeconds(60) }; Assert.AreEqual(0, getAadTokenCount); using (CosmosClient aadClient = new CosmosClient( endpoint, simpleEmulatorTokenCredential, clientOptions)) { Assert.AreEqual(3, getAadTokenCount); await Task.Delay(TimeSpan.FromSeconds(1)); try { ResponseMessage responseMessage = await aadClient.GetDatabase(Guid.NewGuid().ToString()).ReadStreamAsync(); Assert.Fail("Should throw auth error."); } catch (CosmosException ce) when(ce.StatusCode == HttpStatusCode.Unauthorized) { Assert.IsNotNull(ce.Message); Assert.IsTrue(ce.ToString().Contains(errorMessage)); } } }
public async Task AadMockRefreshTest() { int getAadTokenCount = 0; void GetAadTokenCallBack( TokenRequestContext context, CancellationToken token) { getAadTokenCount++; } (string endpoint, string authKey) = TestCommon.GetAccountInfo(); LocalEmulatorTokenCredential simpleEmulatorTokenCredential = new LocalEmulatorTokenCredential( authKey, GetAadTokenCallBack); CosmosClientOptions clientOptions = new CosmosClientOptions() { TokenCredentialBackgroundRefreshInterval = TimeSpan.FromSeconds(1) }; Assert.AreEqual(0, getAadTokenCount); using CosmosClient aadClient = new CosmosClient( endpoint, simpleEmulatorTokenCredential, clientOptions); DocumentClient documentClient = aadClient.ClientContext.DocumentClient; TokenCredentialCache tokenCredentialCache = ((AuthorizationTokenProviderTokenCredential)aadClient.AuthorizationTokenProvider).tokenCredentialCache; Assert.AreEqual(TimeSpan.FromSeconds(1), tokenCredentialCache.BackgroundTokenCredentialRefreshInterval); Assert.AreEqual(1, getAadTokenCount); await aadClient.ReadAccountAsync(); await aadClient.ReadAccountAsync(); await aadClient.ReadAccountAsync(); // Should use cached token Assert.AreEqual(1, getAadTokenCount); // Token should be refreshed after 1 second await Task.Delay(TimeSpan.FromSeconds(1.2)); Assert.AreEqual(2, getAadTokenCount); }
public async Task ContainerIncorrectTest() { List <(string databaseId, string containerId)> containers = new List <(string databaseId, string containerId)> { ("ClientCreateAndInitializeDatabase", "IncorrectContainer") }; (string endpoint, string authKey) = TestCommon.GetAccountInfo(); try { CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(endpoint, authKey, containers); } catch (CosmosException ex) { Assert.IsTrue(ex.StatusCode == HttpStatusCode.NotFound); throw ex; } }
internal static async Task <DocumentCollection> CreateNonPartitionedContainer( Cosmos.Database database, DocumentCollection documentCollection) { (string endpoint, string authKey)accountInfo = TestCommon.GetAccountInfo(); //Creating non partition Container, rest api used instead of .NET SDK api as it is not supported anymore. HttpClient client = new System.Net.Http.HttpClient(); Uri baseUri = new Uri(accountInfo.endpoint); string dateTimeUtc = NonPartitionedContainerHelper.GetUtcDateTime(); string verb = "POST"; string resourceType = "colls"; string resourceId = string.Format("dbs/{0}", database.Id); string resourceLink = string.Format("dbs/{0}/colls", database.Id); client.DefaultRequestHeaders.Add("x-ms-date", dateTimeUtc); client.DefaultRequestHeaders.Add("x-ms-version", NonPartitionedContainerHelper.PreNonPartitionedMigrationApiVersion); string authHeader = NonPartitionedContainerHelper.GenerateMasterKeyAuthorizationSignature( verb, resourceId, resourceType, accountInfo.authKey, "master", "1.0", dateTimeUtc); client.DefaultRequestHeaders.Add("authorization", authHeader); string containerDefinition = documentCollection.ToString(); StringContent containerContent = new StringContent(containerDefinition); Uri requestUri = new Uri(baseUri, resourceLink); DocumentCollection responseCollection = null; using (HttpResponseMessage response = await client.PostAsync(requestUri.ToString(), containerContent)) { response.EnsureSuccessStatusCode(); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.ToString()); responseCollection = await response.Content.ToResourceAsync <DocumentCollection>(); } return(responseCollection); }
public async Task AadMockRefreshRetryTest() { int getAadTokenCount = 0; void GetAadTokenCallBack( TokenRequestContext context, CancellationToken token) { getAadTokenCount++; if (getAadTokenCount <= 2) { throw new RequestFailedException( 408, "Test Failure"); } } (string endpoint, string authKey) = TestCommon.GetAccountInfo(); LocalEmulatorTokenCredential simpleEmulatorTokenCredential = new LocalEmulatorTokenCredential( authKey, GetAadTokenCallBack); CosmosClientOptions clientOptions = new CosmosClientOptions() { TokenCredentialBackgroundRefreshInterval = TimeSpan.FromSeconds(60) }; Assert.AreEqual(0, getAadTokenCount); using (CosmosClient aadClient = new CosmosClient( endpoint, simpleEmulatorTokenCredential, clientOptions)) { Assert.AreEqual(3, getAadTokenCount); await Task.Delay(TimeSpan.FromSeconds(1)); ResponseMessage responseMessage = await aadClient.GetDatabase(Guid.NewGuid().ToString()).ReadStreamAsync(); Assert.IsNotNull(responseMessage); // Should use cached token Assert.AreEqual(3, getAadTokenCount); } }
public async Task EncryptionResourceTokenAuthAllowed() { User keyManagerUser = EncryptionTests.databaseCore.GetUser(Guid.NewGuid().ToString()); await EncryptionTests.databaseCore.CreateUserAsync(keyManagerUser.Id); PermissionProperties keyManagerUserPermission = await keyManagerUser.CreatePermissionAsync( new PermissionProperties(Guid.NewGuid().ToString(), PermissionMode.All, EncryptionTests.keyContainer)); CosmosDataEncryptionKeyProvider dekProvider = new CosmosDataEncryptionKeyProvider(new TestKeyWrapProvider()); TestEncryptor encryptor = new TestEncryptor(dekProvider); (string endpoint, string _) = TestCommon.GetAccountInfo(); CosmosClient clientForKeyManagerUser = new CosmosClientBuilder(endpoint, keyManagerUserPermission.Token) .WithEncryptor(encryptor) .Build(); Database databaseForKeyManagerUser = clientForKeyManagerUser.GetDatabase(EncryptionTests.databaseCore.Id); await dekProvider.InitializeAsync(databaseForKeyManagerUser, EncryptionTests.keyContainer.Id); DataEncryptionKeyProperties readDekProperties = await dekProvider.DataEncryptionKeyContainer.ReadDataEncryptionKeyAsync(EncryptionTests.dekId); Assert.AreEqual(EncryptionTests.dekProperties, readDekProperties); }
public async Task AadMockTest(ConnectionMode connectionMode) { int requestCount = 0; string databaseId = Guid.NewGuid().ToString(); string containerId = Guid.NewGuid().ToString(); using (CosmosClient cosmosClient = TestCommon.CreateCosmosClient()) { Database database = await cosmosClient.CreateDatabaseAsync(databaseId); Container container = await database.CreateContainerAsync( containerId, "/id"); } (string endpoint, string authKey) = TestCommon.GetAccountInfo(); LocalEmulatorTokenCredential simpleEmulatorTokenCredential = new LocalEmulatorTokenCredential(authKey); CosmosClientOptions clientOptions = new CosmosClientOptions() { ConnectionMode = connectionMode, ConnectionProtocol = connectionMode == ConnectionMode.Direct ? Protocol.Tcp : Protocol.Https, }; if (connectionMode == ConnectionMode.Direct) { long lsn = 2; clientOptions.TransportClientHandlerFactory = (transport) => new TransportClientWrapper(transport, interceptorAfterResult: (request, storeResponse) => { // Force a barrier request on create item. // There needs to be 2 regions and the GlobalCommittedLSN must be behind the LSN. if (storeResponse.StatusCode == HttpStatusCode.Created) { if (requestCount == 0) { requestCount++; lsn = storeResponse.LSN; storeResponse.Headers.Set(Documents.WFConstants.BackendHeaders.NumberOfReadRegions, "2"); storeResponse.Headers.Set(Documents.WFConstants.BackendHeaders.GlobalCommittedLSN, "0"); } } // Head request is the barrier request // The GlobalCommittedLSN is set to -1 because the local emulator doesn't have geo-dr so it has to be // overridden for the validation to succeed. if (request.OperationType == Documents.OperationType.Head) { if (requestCount == 1) { requestCount++; storeResponse.Headers.Set(Documents.WFConstants.BackendHeaders.NumberOfReadRegions, "2"); storeResponse.Headers.Set(Documents.WFConstants.BackendHeaders.GlobalCommittedLSN, lsn.ToString(CultureInfo.InvariantCulture)); } } return(storeResponse); }); } using CosmosClient aadClient = new CosmosClient( endpoint, simpleEmulatorTokenCredential, clientOptions); TokenCredentialCache tokenCredentialCache = ((AuthorizationTokenProviderTokenCredential)aadClient.AuthorizationTokenProvider).tokenCredentialCache; // The refresh interval changes slightly based on how fast machine calculate the interval based on the expire time. Assert.IsTrue(15 <= tokenCredentialCache.BackgroundTokenCredentialRefreshInterval.Value.TotalMinutes, "Default background refresh should be 25% of the token life which is defaulted to 1hr"); Assert.IsTrue(tokenCredentialCache.BackgroundTokenCredentialRefreshInterval.Value.TotalMinutes > 14.7, "Default background refresh should be 25% of the token life which is defaulted to 1hr"); Database aadDatabase = await aadClient.GetDatabase(databaseId).ReadAsync(); Container aadContainer = await aadDatabase.GetContainer(containerId).ReadContainerAsync(); ToDoActivity toDoActivity = ToDoActivity.CreateRandomToDoActivity(); ItemResponse <ToDoActivity> itemResponse = await aadContainer.CreateItemAsync( toDoActivity, new PartitionKey(toDoActivity.id)); // Gateway does the barrier requests so only direct mode needs to be validated. if (connectionMode == ConnectionMode.Direct) { Assert.AreEqual(2, requestCount, "The barrier request was never called."); } toDoActivity.cost = 42.42; await aadContainer.ReplaceItemAsync( toDoActivity, toDoActivity.id, new PartitionKey(toDoActivity.id)); await aadContainer.ReadItemAsync <ToDoActivity>( toDoActivity.id, new PartitionKey(toDoActivity.id)); await aadContainer.UpsertItemAsync(toDoActivity); await aadContainer.DeleteItemAsync <ToDoActivity>( toDoActivity.id, new PartitionKey(toDoActivity.id)); }