Share via

Webjob issue with node.js

Sabino Bellanima 1 Reputation point
2022-05-31T13:43:42.137+00:00

Hi all,

i don't know why i can't run a webjob written in nodejs on Azure.
I have set up correctly the WEBSITE_NODE_DEFAULT_VERSION to 14.17.0 (the same that is installed on my pc).
The code is correct because on my laptop it works very well but when I deploy it on Azure and try to run the webjob i receive always the same error:

Here an example:
[05/31/2022 13:25:52 > 00ceeb: SYS INFO] Status changed to Initializing
[05/31/2022 13:25:52 > 00ceeb: SYS INFO] Run script 'app.js' with script host - 'NodeScriptHost'
[05/31/2022 13:25:52 > 00ceeb: SYS INFO] Status changed to Running
[05/31/2022 13:25:53 > 00ceeb: ERR ]
[05/31/2022 13:25:53 > 00ceeb: ERR ] D:\home\site\wwwroot\App_Data\jobs\triggered\bulkApprovalMail\app.js:9
[05/31/2022 13:25:53 > 00ceeb: ERR ] const query = SELECT * FROM users WHERE active = 1;
[05/31/2022 13:25:53 > 00ceeb: ERR ] ^
[05/31/2022 13:25:53 > 00ceeb: ERR ] SyntaxError: Unexpected token ILLEGAL

I have always the SyntaxError for every code i put on the file.

Can you please help me?
Thanks
Sabino

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,336 Reputation points Microsoft Employee Moderator
    2022-06-01T04:28:38.69+00:00

    It would be better if you provide a larger snippet of what's before const query but one thing I'm noticing (not sure if it's a typo or not) is that your select statement isn't encapsulated in a '' or "". That could be what's wrong or it may not be.

    Here's another food for thought, have you considered running your web job as an Azure Function instead? Better support for npm and your app service doesn't have to be set to Always On. It also may alleviate your original issue.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.