You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use ExecuteStateTransactionAsync() with Azure Cosmos DB state store, but it does not work. I keep getting "error while executing state transaction: transaction failed due to operation 0 which failed with status code 400" exception. Using .NET or the API directly does not make a difference. I am using Dapr version 1.13.0.
I tried what is in the Dapr state management documentation here:
Expected Behavior
Executing transaction operations should work.
Actual Behavior
An exception is thrown : "error while executing state transaction: transaction failed due to operation 0 which failed with status code 400"
Steps to Reproduce the Problem
This should work:
var random = new Random();
int orderId = random.Next(1, 1000);
var requests = new List<StateTransactionRequest>()
{
new("order_1", JsonSerializer.SerializeToUtf8Bytes(orderId.ToString()), StateOperationType.Upsert)
};
await _daprClient.ExecuteStateTransactionAsync(STORE_NAME, requests, cancellationToken: cancellation);
Using PowerShell to target the API directly should also work:
For CosmosDB you must specify the metadata property partitionKey which will apply to all operations within your transaction. CosmosDB does not support transaction across partitions.
If you include the metadata property (which has to be done manually) this will work.
Hi,
I'm trying to use ExecuteStateTransactionAsync() with Azure Cosmos DB state store, but it does not work. I keep getting
"error while executing state transaction: transaction failed due to operation 0 which failed with status code 400"
exception. Using .NET or the API directly does not make a difference. I am using Dapr version1.13.0
.I tried what is in the Dapr state management documentation here:
Expected Behavior
Executing transaction operations should work.
Actual Behavior
An exception is thrown :
"error while executing state transaction: transaction failed due to operation 0 which failed with status code 400"
Steps to Reproduce the Problem
This should work:
Using PowerShell to target the API directly should also work:
Invoke-RestMethod -Method Post -ContentType 'application/json' -Body '{"operations": [{"operation":"upsert", "request": {"key": "order_1", "value": "150"}}, {"operation":"upsert", "request": {"key": "order_2", "value": "250"}}]}' -Uri 'http://localhost:3500/v1.0/state/statestorecosmos/transaction'
The text was updated successfully, but these errors were encountered: