Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table trigger with {id} isn't working #249

Closed
diberry opened this issue Apr 22, 2024 · 1 comment
Closed

Table trigger with {id} isn't working #249

diberry opened this issue Apr 22, 2024 · 1 comment
Labels
bug Something isn't working upstream

Comments

@diberry
Copy link

diberry commented Apr 22, 2024

Investigative information

Please provide the following:

  • Timestamp:
  • Function App name:
  • Function name(s) (as appropriate):
  • Invocation ID:
  • Region:

Repro steps

Provide the steps required to reproduce the problem:

Example:

  1. Set up Storage table
image
  1. Set up and run v4 function code
const { app, input } = require('@azure/functions');

const tableInput = input.table({
    partitionKey: 'car',
    tableName: 'product',
   rowKey: '{id}',
   connection: 'AzureWebJobsStorage',
});

app.http('httpAndTable', {
    methods: ['GET'],
    connection: 'AzureWebJobsStorage',
    route: "products/{id}",
    extraInputs: [tableInput],
    handler: (request, context) => {

        try {

            context.log(`id: ${request.params.id}`); 

            const product = context.extraInputs.get(tableInput);
            context.log(`Product: ${JSON.stringify(product)}`);

            if (product) {
                return {
                    status: 200,
                    jsonBody:product
                };
            } else {
                return {
                    status: 400,
                    body: `There is no data for ID: ${id}`
                };
            }
        } catch (err) {
            context.log(`Error: ${err}`);
            return {
                status: 500,
                body: 'Internal Server Error'
            }
        }
    }
});
  1. Notice that table binding, route, and context.log all use {id}. The URL is /api/products/891bab72-7ac0-4680-82ca-cd07e317bd5c, and the context.log displays that id. The function returns all rows instead of 1.
image
  1. If the route returns the id correctly in the context.log, why isn't the table binding reducing the results to that row?
image

Expected behavior

Provide a description of the expected behavior.

Actual behavior

Provide a description of the actual behavior observed.

Known workarounds

Provide a description of any known workarounds.

Related information

Provide any related information

  • Programming language used
  • Links to source
  • Bindings used
@ejizba
Copy link
Contributor

ejizba commented Apr 24, 2024

Looks like this is a known issue: Azure/azure-webjobs-sdk-extensions#848

I would recommend this as a workaround:

filter: "RowKey eq '{rowKey}'"

Closing in favor of linked issue, especially as this is not unique to Node.js

@ejizba ejizba closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@ejizba ejizba added upstream bug Something isn't working labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants