azure-functions-host
azure-functions-host copied to clipboard
Feature: Upsert Table Entity: Support Changing Existing Entities
Using Binding alone, it is not possible to modify a Table Entity.
Investigative information
Please provide the following:
- Timestamp: 2017-07-07T13:37:47.269
- Function App name: told-stack-demo
- Function name(s) (as appropriate): http-to-table
- Invocation ID: 8fe9fdae-6907-4cb2-9982-de43a7a4e5f2
- Region: East US 2
2017-07-07T13:37:47.269 Function started (Id=8fe9fdae-6907-4cb2-9982-de43a7a4e5f2)
2017-07-07T13:37:49.815 Function completed (Success, Id=8fe9fdae-6907-4cb2-9982-de43a7a4e5f2, Duration=2547ms)
2017-07-07T13:37:50.002 Exception while executing function: Functions.http-to-table. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.WindowsAzure.Storage: The specified entity already exists.
RequestId:756cc6df-0002-0065-4726-f70b5c000000
Time:2017-07-07T13:37:49.6169943Z.
Repro steps
- Bind to a Table with 'out' direction
- Use an existing PartitionKey and RowKey
Expected behavior
Provide a description of the expected behavior.
- InsertOrMerge Behavior:
- If no row exists, insert it
- If a row exists, replace column values with provided values
Actual behavior
Provide a description of the actual behavior observed.
2017-07-07T13:37:50.002 Exception while executing function: Functions.http-to-table. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.WindowsAzure.Storage: The specified entity already exists.
Known workarounds
Provide a description of any known workarounds.
- Use the Azure Storage SDK
Problems with the Workaround:
- with Node this requires bundling and adds 2MB to the script size
- bundling is required because of poor performance with node_modules
Related information
Provide any related information
- Typescript
- Node.js
Source
function.json:
{
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"authLevel": "anonymous",
"route": "api/http-to-table/{table}/{partition}/{row}"
},
{
"name": "res",
"type": "http",
"direction": "out"
},
{
"name": "inOutputTable",
"type": "table",
"direction": "in",
"tableName": "{table}",
"partitionKey": "{partition}",
"rowKey": "{row}",
"connection": "AZURE_STORAGE_CONNECTION_STRING"
},
{
"name": "outOutputTable",
"type": "table",
"direction": "out",
"tableName": "{table}",
"partitionKey": "{partition}",
"rowKey": "{row}",
"connection": "AZURE_STORAGE_CONNECTION_STRING"
}
],
"disabled": false
}
This is an attempt to mimic what was reported to work in C# at:
https://stackoverflow.com/a/44900064/567524
if (context.bindings.inOutputTable) {
context.bindings.outOutputTable = context.bindings.inOutputTable;
for (let k in data) {
context.bindings.outOutputTable[k] = data[k];
}
} else {
context.bindings.outOutputTable = data;
}
This is a feature we need to add to support upserting. We only currently support insert.
Ok, I changed the title to better reflect that.
If you could point me to the correct location, I could write the code and do a pull request.
Literally just hit this problem, really rather not have to drop back to C# and using the full Azure Storage library, love to see if there was a workaround
I could find no workaround using the binding.
Also, heads up: Blobs also blow up, but in a different situation (if you try to read a blob that doesn't exist):
So we have the following situation:
Tables
- in (Exists)
- in (Not Found)
- out (Create)
- FAIL out (Modify)
Blobs:
- in (Exists)
- FAIL in (Not Found)
- out (Create)
- out (Modify)
Also, you can't set Blob Metadata with the binding if you need that.
The Azure Storage SDK works fine and my performance tests show no significant difference between using the bindings and using the Node SDK. However, I have to bundle everything with webpack for it to perform and its not a simple function anymore when you need a build process.
Thanks. That's a real shame.
If you're not using bindings you're losing 60% of what Functions is all about IMO, plus I really don't want to mess with webpack. I think I'll switch to a regular Web or API App until there's some progress on this with the WebJobSDK.
any news on this? this seems rather essential.
I agree with @ThomasPe - this would be an excellent feature.
Any news on this
Anything? This is a glaring omission.
We currently do not have a plan for when we might address this feature gap. Our current focus is on functions V2 (including webjobs v3) and at this time we are not tracking this gap as a blocker for that release.
With respect, why? It seems as though using bindings to accomplish operations like this is exactly the intention for functions. If you can't even edit the data in tables then it should at least be documented up front (on https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#output) with instructions on how to achieve it.
It really makes sense to call the upsert as the basic feature for functions . If not document them properly so that people like us dont end up spending time in rework.
@unwitting It is simply a matter of prioritization and working with a limited set of resources. We are spending our time on issues that impact reliability, performance, or having the right logs to track down a problem. We are also working on issues that completely block a customer from adopting functions (i.e. issues with no workaround). The feature discussed in this issue does not fall into any of those categories and that is why it is not being worked on.
See here for a docs PR to make this clearer: https://github.com/MicrosoftDocs/azure-docs/pull/6481
Awesome, thanks for the docs update. I didn't realise the azure-docs are OS, that's great.
Any update on this issue? does it support the upserting now? Thanks
Man, what a disappointing waste of time. The documentation around node functions + table storage bindings is so bad.
Any update on this?
Any updates?
Still not? Come on!