Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
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.