System.Uri error in Container.ReadThroughputAsync
See original GitHub issueDescribe the bug
When calling Container.ReadThroughputAsync()
on a non-null container that has a throughput value (400 in this case), CosmosOffers.ReadThroughputAsync
fails due to a “Value cannot be null” error in the System.Uri
constructor.
To Reproduce
Get a container and call ReadThroughputAsync()
on it:
CosmosClient _cosmosClient = new CosmosClient(
_configuration.Endpoint,
_configuration.AuthKey,
new CosmosClientOptions
{
ConnectionMode = _configuration.ConnectionMode,
ConsistencyLevel = ConsistencyLevel.Session,
GatewayModeMaxConnectionLimit = _configuration.MaxConnectionLimit,
RequestTimeout = _configuration.RequestTimeout,
MaxRetryAttemptsOnRateLimitedRequests = _configuration.MaxRetryAttemptsOnThrottledRequests,
MaxRetryWaitTimeOnRateLimitedRequests = TimeSpan.FromSeconds(_configuration.MaxRetryWaitTimeInSeconds),
Serializer = new CosmosJsonSerializer(_jsonSerializer), // Custom CosmosSerializer
});
Database database = await _cosmosClient.CreateDatabaseIfNotExistsAsync(databaseId);
await database.CreateContainerIfNotExistsAsync(containerId, _configuration.PartitionKey, 400);
Container container = _cosmosClient.GetContainer(databaseId, containerId);
int? throughput = await container.ReadThroughputAsync();
Expected behavior
The method should return a value (in my case, I expect 400).
Actual behavior
A System.ArgumentNullException
is thrown (see message and stack trace below).
Environment summary SDK Version: 3.1.1 OS Version (e.g. Windows, Linux, MacOSX): Windows
Additional context
Exception message:
Value cannot be null.
Parameter name: uriString
Stack trace:
at System.Uri..ctor(String uriString, UriKind uriKind)
at Microsoft.Azure.Cosmos.CosmosOffers.<ReadThroughputAsync>d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Cosmos.ContainerCore.<ReadThroughputAsync>d__24.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Cosmos.ContainerCore.<ReadThroughputAsync>d__23.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AH.DS.Online.Common.Providers.CosmosDB.DocumentClientAdapter.<ElasticScaleCollectionThroughputAsync>d__21.MoveNext() in C:\Users\b_b\source\repos\ah-ds-online\src\ah-ds-online-common\Common.Providers.CosmosDB\DocumentClientAdapter.cs:line 197
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at AH.DS.Online.Publisher.Common.Services.ThroughputScaleService.<ScaleUpThroughputAsync>d__3.MoveNext() in C:\Users\b_b\source\repos\ah-ds-online\src\ah-ds-online-publisher\Publisher.Common\Services\ThroughputScaleService.cs:line 23
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at AH.DS.Online.Publisher.Common.Commands.MetadataProcessorCommand.<Execute>d__4.MoveNext() in C:\Users\b_b\source\repos\ah-ds-online\src\ah-ds-online-publisher\Publisher.Common\Commands\MetadataProcessorCommand.cs:line 36
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c# - Failure in Microsoft.Azure.Cosmos.Container. ...
I am porting some C# code from Microsoft.Azure.Documents to Microsoft.Azure.Cosmos. I created a small test case to try to get it working just ......
Read more >Container.ReadThroughputAsync Method
Gets container throughput in measurement of request units per second in the Azure Cosmos service. ReadThroughputAsync(RequestOptions, CancellationToken).
Read more >Troubleshooting Azure Cosmos DB Performance
In the Explorer pane, select the DataTypes.cs. Review the file, notice it contains the data classes you will be working with in the...
Read more >Not able to change cosmosdb container throughput from ...
Coding example for the question Not able to change cosmosdb container throughput ... ReadAsStringAsync(); throw new Exception($"Error changing throughput ...
Read more >Read current collection throughput of Cosmos DB in C#
ReadThroughputAsync (); var containerThroughput = await container. ... Error While writing Data into Cosmos DB (MongoDB API) - Shared throughput collection ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have tried a reduced test case in a Console App, and cannot replicate the issue: reading and replacing the throughput work as expected.
The main thing that was changed when updating to Cosmos SDK 3 was adding the custom
CosmosSerializer
(a wrapper around Newtonsfot.Json). Could that be the culprit?Yea sound reasonable , custom serializer could play the role here. Will pick this item next week. Thanks for all the detail explanation of the issue , really appreciate that.