azure-sdk-for-cpp
azure-sdk-for-cpp copied to clipboard
`TableClient::SubmitTransaction()` doesn't work for `TransactionActionType` `InsertReplace`
Describe the bug
TableClient::SubmitTransaction() with TransactionStep.Action set to InsertReplace doesn't insert entities. It works fine with action Add, or when using Upsert method without transaction.
To Reproduce Steps to reproduce the behavior:
- run the code snippet
Code Snippet
#include <iostream>
#include <azure/data/tables.hpp>
#include <azure/identity/default_azure_credential.hpp>
int main() {
auto cred = std::make_shared<Azure::Identity::DefaultAzureCredential>();
std::string tableName = "<your table name>";
std::string storageUrl= "<your storage account url>";
auto tableClient = Azure::Data::Tables::TableClient(storageUrl, tableName, cred);
auto serviceClient = Azure::Data::Tables::TableServiceClient(storageUrl, cred);
serviceClient.CreateTable(tableName);
auto transaction = std::vector<Azure::Data::Tables::Models::TransactionStep>(1);
auto entity = Azure::Data::Tables::Models::TableEntity();
entity.SetPartitionKey("partition");
entity.SetRowKey("rowKey");
transaction[0].Entity = entity;
transaction[0].Action = Azure::Data::Tables::Models::TransactionActionType::InsertReplace;
tableClient.SubmitTransaction(transaction);
auto response = tableClient.QueryEntities();
std::cout << "returned " << response.TableEntities.size() << " entities"; // got 0, expected 1
}
Expected behavior Expected to insert 1 entity, as per code snippet
Setup OS: WSL, Ubuntu 22.04 IDE : VS Code Version of the Library used: azure-data-tables-cpp, 1.0.0-beta.2 (pulled from VCPKG)
Thank you for your feedback. Tagging and routing to the team member best able to assist.
Thank you for the report, looking into it .