serverless-express icon indicating copy to clipboard operation
serverless-express copied to clipboard

How can I use context.log in Azure functions?

Open Jingasan opened this issue 3 years ago • 4 comments

I don't know how to use context.log with serverless-express and Azure functions. Please tell me how to use context.log.

Jingasan avatar Aug 07 '22 09:08 Jingasan

Can you use getCurrentInvoke().context? See https://github.com/vendia/serverless-express/blob/mainline/examples/azure-http-function-v4/HttpExample/app.js#L23

brettstack avatar Aug 08 '22 09:08 brettstack

Thank you for your reply. But getCurrentInvoke().context doesn't work. [Code] image [Error] image

Jingasan avatar Aug 08 '22 19:08 Jingasan

@Jingasan Because the azure way to pass the arguments to the handler (see here), context inside getCurrentInvoke() represents the event and event represents the context.

So to make this work, call getCurrentInvoke().event.log.

@brettstack Also the azure examples are broken because they don't reflect current behavior, should I create an issue to track the fixes?

H4ad avatar Aug 13 '22 15:08 H4ad

@H4ad Thank you for telling me about it. It works !

Jingasan avatar Aug 13 '22 19:08 Jingasan