Please provide a succinct description of the issue.
Provide the steps required to reproduce the problem
Use table storage output binding in node function in App Service plan
Output table item with existing RowKey, setting Etag: "*"
A upsert operation is executed as mentioned here
Function fails with: The specified entity already exists.
The docs state that upsert is not supported but there seems to be something here that should do the trick? https://github.com/Azure/azure-webjobs-sdk/blob/ea55e6ef5439b1059b43825cb9d40cc12ae219bc/src/Microsoft.Azure.WebJobs.Extensions.Storage/Tables/TableEntityWriter.cs#L100
I didn't even know that was a feature -- but it looks like we have tests that verify it works. I just ran through it manually and it worked as well.
Can you share exactly what your code looks like?
@brettsam thanks for checking. This is my code
module.exports = function(context, message) {
const existingOrg = context.bindings.existingOrg;
const updatedOrg = Object.assign(existingOrg, message.update, {
__etag: "*",
etag: "*",
ETag: "*"
});
context.log("updated org:", updatedOrg);
context.bindings.updatedOrg = updatedOrg;
context.done();
};
Ahh -- this is in node! I missed that part. @mhoeger -- you don't know if there's a trick to set the ETag on a TableEntity from node, do you? I'm going to look through our converters to see if there's something missing here.
Thank you! I actually just tried it in C# but it seems challenging just to copy some arbitrary attributes from an incoming JSON message to a table entity.
So if this could be solved in node that would be awesome.
I believe the issue is here: https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Extensions.Storage/Tables/Config/TablesExtensionConfigProvider.cs#L153. We explicitly look for PartitionKey / RowKey and apply them correctly when taking your object from node. We do not check ETag, however.
Great. So looks like this can be fixed with little effort? If so when can we expect it to be shipped?
I would also need this feature 馃檹
It's a valid feature and potentially just a few lines of code, but not yet at the top of the backlog. Keep letting us know (via 馃憤 or whatever) that this would be a worthwhile feature to implement more explicitly in the extension. For now the recommended approach would be leveraging the Table SDKs directly in the Azure Function code (e.g. the Node Azure Table SDK) to perform an upsert operation. In general bindings are a convenience (and a great one at that 馃槃 ) but can accomplish the same behaviors by leveraging the SDKs if need more flexibility or control. Let us know. Thanks
Would be great to have this feature instead of having to use the outdated and bloated storage API.
Most helpful comment
It's a valid feature and potentially just a few lines of code, but not yet at the top of the backlog. Keep letting us know (via 馃憤 or whatever) that this would be a worthwhile feature to implement more explicitly in the extension. For now the recommended approach would be leveraging the Table SDKs directly in the Azure Function code (e.g. the Node Azure Table SDK) to perform an upsert operation. In general bindings are a convenience (and a great one at that 馃槃 ) but can accomplish the same behaviors by leveraging the SDKs if need more flexibility or control. Let us know. Thanks