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

Is it possible to access invocationid in sql input #52

Open
DVGY opened this issue Sep 19, 2024 · 4 comments
Open

Is it possible to access invocationid in sql input #52

DVGY opened this issue Sep 19, 2024 · 4 comments

Comments

@DVGY
Copy link

DVGY commented Sep 19, 2024

Is it possible to access invocationid in sql input ?

@ejizba
Copy link
Contributor

ejizba commented Sep 19, 2024

Hi @DVGY you can access the invocationId on the context object, which is the second argument to your function

@DVGY
Copy link
Author

DVGY commented Sep 19, 2024

@ejizba thanks for reply. Sorry I did not provide full info. I was going through the below code. Is it possible to somehow access the invocationid inside the parameters. Something like this

input.sql({
parameters:@id={context.invocationid} 
//..rest of the parameters
})

Reference code in this repo

import { app, HttpRequest, HttpResponseInit, input, InvocationContext } from '@azure/functions';

const sqlInput = input.sql({
    connectionStringSetting: 'e2eTest_sql',
    commandText: 'select * from dbo.e2eSqlNonTriggerTable where id = @id',
    commandType: 'Text',
    parameters: '@id={Query.id}',
});

export async function httpTriggerSqlInput(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
    context.log(`httpTriggerSqlInput was triggered`);
    const items = context.extraInputs.get(sqlInput);
    return { jsonBody: items };
}

app.http('httpTriggerSqlInput', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    extraInputs: [sqlInput],
    handler: httpTriggerSqlInput,
});import { app, HttpRequest, HttpResponseInit, input, InvocationContext } from '@azure/functions';

const sqlInput = input.sql({
    connectionStringSetting: 'e2eTest_sql',
    commandText: 'select * from dbo.e2eSqlNonTriggerTable where id = @id',
    commandType: 'Text',
    parameters: '@id={Query.id}',
});

export async function httpTriggerSqlInput(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
    context.log(`httpTriggerSqlInput was triggered`);
    const items = context.extraInputs.get(sqlInput);
    return { jsonBody: items };
}

app.http('httpTriggerSqlInput', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    extraInputs: [sqlInput],
    handler: httpTriggerSqlInput,
});

@ejizba
Copy link
Contributor

ejizba commented Sep 19, 2024

Ah that makes more sense. These are relevant docs: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-expressions-patterns

Unfortunately I'm not aware of a way to use the invocation id directly and I don't see it in the docs. If that's something you need, the following repo would be a better place to file an issue to add support: https://github.com/Azure/azure-functions-host/issues

@DVGY
Copy link
Author

DVGY commented Sep 20, 2024

Thanks alot will look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants