A strange bug in Azure Cosmos DB SQL API account (SDK Version 3 Preview)

It is important to read the official documentation. Sometimes, you feel the need to add some value. After seeing the tweet below, I spent almost my weekend studying the new tutorial which I highly recommend for beginners with Azure Cosmos DB.

Used Versions

  • Microsoft Azure Cosmos DB Client library = 3.0.0.1-preview
  • .NET Core 3.0 Preview 1
  • Visual Studio 2019 Preview 1 or Visual Studio Code Insiders 13.1
  • Windows 10 Enterprise N 1809

In the first round, I used Visual Studio 2019 Preview and boom I get the following horrible exception. The tutorial is made up with 11 steps. Something sucks at the eighth step.

Beginning operations...

Created Database: FamilyDatabase

Created Container: FamilyContainer

Item in database with id: Andersen.1 already exists

Item in database with id: Wakefield.7 already exists

Running query: SELECT * FROM c WHERE c.LastName = 'Andersen'

        Read {"id":"Andersen.1","LastName":"Andersen","Parents":[{"FamilyName":null,"FirstName":"Thomas"},{"FamilyName":null,"FirstName":"Mary Kay"}],"Children":[{"FamilyName":null,"FirstName":"Henriette Thaulow","Gender":"female","Grade":5,"Pets":[{"GivenName":"Fluffy"}]}],"Address":{"State":"WA","County":"King","City":"Seattle"},"IsRegistered":true}

Error: System.AggregateException: One or more errors occurred. (Exception has been thrown by the target of an invocation.) ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(Boolean overflow, String overflowResourceKey)
   at System.Double.Parse(String s)
   at Microsoft.Azure.Cosmos.CosmosResponseMessageHeaders.set__requestCharge(String value)

I took the same source code folder and I compiled it in another Azure VM. It runs without any issue. I changed from Visual Studio 2019 Preview to Visual Studio Code because I was suspecting the tooling. In my laptop, the console app crashes but it works fine in my Azure VM.

The bug is impossible to reproduce it in other machines with same configuration. I decided to create an issue on the GitHub repo of NET SDK for Azure Cosmos DB for the core SQL API.

azure Cosmos DB

Hi, I'm Maher, Development Technologies MVP. I'm blogging about ASP.NET Core and Microsoft Azure.