Node.js Azure function input binding for Table storage ignores rowKey
I have a simple Node.js Azure function (runtime v4) with input binding for Azure Table storage as follows:
import { app, HttpRequest, HttpResponseInit, InvocationContext, input } from "@azure/functions";
const tableInput = input.table({
tableName: 'Person',
partitionKey: 'Test',
rowKey: '{key}',
connection: 'AzureWebJobsStorage',
});
export async function readTable(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);
const tableData = context.extraInputs.get(tableInput)
return { jsonBody: tableData };
};
app.http('readTable', {
methods: ['GET'],
route: 'read/{key}',
extraInputs: [tableInput],
authLevel: 'anonymous',
handler: readTable
});
The result of this function is however all the rows in Person table with Test partition key, instead of just one (or none) with given rowKey.
The behaviour is the same localy (with Azurite as storage emulator) and when deployed to Azure.
Node.js v20, @azure/functions v4.5.0
Same issue here
Node.js v18.20.4 @azure/functions v4.5.1
Hello @yohny, Thanks for reporting. This happens because the Node.js v4 model doesn’t fully support single-entity table input binding with rowKey. It defaults to fetching all rows with the given partitionKey. To fetch a specific entity, please try using the Azure Tables SDK directly in your function.
/bot not-stale
Hello @yohny,
Just a follow up regarding feedback on the above response provided from our side.
Retrieving single record using the Azure Tables SDK works as expected. But I believe this isuse is still valid, as retrieval using binding does not work as expected. Or did I misunderstand something?
Thanks for confirming that the SDK works as expected. You’re not misunderstanding. In the current Node.js v4 programming model, the binding only filters by partitionKey, even if rowKey is specified. This is a known limitation, not the intended behavior for single-entity access.
/bot not-stale
Hi @yohny,
Just a follow up regarding feedback on the above response provided from our side.
feedback to what? there was no additional info requested, or am I missing something?
@yohny, Apologies for the confusion earlier.
Just to clarify, In the current Node.js v4 programming model, even when both partitionKey and rowKey are set in the Table input binding, only the partitionKey is used for filtering. That’s why you’re seeing all rows with the Test partition, the rowKey is unfortunately ignored. This is a known limitation. Using the Azure Tables SDK, as you’ve done, is currently the most reliable way to retrieve a single record using both keys.
Let me know if you’d like me to pass this as product feedback on your behalf.
sure, you can pass it as product feedback anyway, I would like to keep this issue open until its fixed