1

The issue only relates to azurite as using an actual Azure table works fine. I noticed searching in azurite doesn't return ETag for any entity.

Using the below entity, TableOperation.Insert always succeeds but always returns Conflict 409, even though the new entity was added to the table.

TableOperation.InsertOrReplace always succeeds and doesn't throw an exception.

There are no duplicates in the table so there's no obvious reason why Insert should fail and InsertOrReplace should succeed. Is there any reason why Insert would succeed and fail at the same time?

public class MessageQEntity : TableEntity
{
    public string Message { get; set; }
    public string Status { get; set; }

    public MessageQEntity()
    {
        PartitionKey = "Region";
        RowKey = Guid.NewGuid().ToString();
    }
}
codebrane
  • 4,290
  • 2
  • 18
  • 27

1 Answers1

0

The concept is very simple. Conflict always arises when you are trying to insert a new entity but there's already an entity in the table with the same PartitionKey and RowKey.

In your case, as you did not show me the code, you should be reusing the same object of MessageQEntity to insert new entities by updating Message and/or Status fields, but not RowKey.

It's straightforward why InsertOrReplace works as expected, as it understands there's an existing entity and so, it replaces that entity with the newly added entity :)

Deepak
  • 2,660
  • 2
  • 8
  • 23
  • thanks for that but the table is empty. I used powershell to delete the table, create a new one, then TableOperation.Insert and it raises the conflict. It doesn't occur on actual storage tables in Azure, only on azurite tables. – codebrane Jan 24 '21 at 12:57
  • Can you make sure Azurite supports Table Insert operation? I think it is still in their pipeline as Azurite mostly supports Blob and storage queue services and partially Tables. – Deepak Jan 24 '21 at 16:36
  • yes it's Azurite V2 as V3 doesn't fully support tables yet – codebrane Jan 25 '21 at 08:53