CodeGenieApp / serverless-express

Run Express and other Node.js frameworks on AWS Serverless technologies such as Lambda, API Gateway, Lambda@Edge, and more.
https://codegenie.codes
Apache License 2.0
5.14k stars 667 forks source link

How can I use context.log in Azure functions? #545

Open Jingasan opened 2 years ago

Jingasan commented 2 years ago

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

brettstack commented 2 years ago

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

Jingasan commented 2 years ago

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

H4ad commented 2 years ago

@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?

Jingasan commented 2 years ago

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