Microsoft.Azure.Management.CosmosDB.Fluent fails when setting IpRangeFilter

Viewed 668

When using the Fluent Azure Cosmos Api (1.22.2) to update the ip range:

var cosmos = azure.CosmosDBAccounts.GetByResourceGroup(cosmosResourceGroup, cosmosAccountName);
cosmos.Update().WithIpRangeFilter(ipRangeFilter).Apply();

I receive:

Cannot update EnableMultipleWriteLocations flag and other properties at the same time.\r\nActivityId: 2602d107-0e8e-4631-a421-01b65127a064, Microsoft.Azure.Documents.Common/2.4.0.0

On further inspection I can see that a Cosmos Database that has false set for EnableMultipleWriteLocations does not fail, whereas one with true does.

1 Answers

It looks as though the fluent api (or the receiving end of the API calls) is interpreting a non-specified EnableMultipleWriteLocations as false.

Therefore if you update a single property (such as IpRangeFilter) without specifying the EnableMultipleWriteLocations boolean for a Cosmos DB instance that has EnableMultipleWriteLocations set to true, it will assume you are trying to change it to false and fail (because changing from true to false is not permitted, and as they error suggests certainly not permitted with additional property changes).

My fix therefore was to manually call the Azure REST API and send the correct EnableMultipleWriteLocations value (based on a GET call prior to PUT) with the other updates.

Related