How can I define the node version that is used to run azure webjobs?
The server currently executes my code with v0.11 and fails since I use features that require node >8
The web app itself runs on node 8 just fine, but the version for webjobs seems to be independent of the webserver itself.
On Azure WebApp, for Node.js runtime, there is a default version which be older that 0.10.40 or others like 0.11 as you said. If you want to change the default Node version for running your webjob, there are two ways below to configure it.
To set the value of WEBSITE_NODE_DEFAULT_VERSION with the version number you want in Application settings tab of Azure portal. You can refer to my answer for the existing SO thread Azure NodeJS version.
To create a zip file as webjob which wrapped your Node JavaScript and a bootstrap file, please refer to the offical document Supported file types for scripts or programs. For example, a WebJob zip file includes index.js and run.bat as below, you can set the PATH environment to add the Node runtime path supported by Azure (you can list all version of NodeJS on Azure by following my answer above) to make it works.
index.js
console.log(process.version)
run.bat
set PATH=D:/Program Files (x86)/nodejs/8.11.1/;%PATH%
node index.js
Then, following the below figure steps, you can add & run your webjob zip file and see the output result via Logs.
Here is my result in Logs when I set my Node runtime version 10.14.1 as below.
Related
I'm trying to deploy a Laravel + Vue app over an Azure App Service - Web App. It is however very unclear and I cannot find any proper solution inside Microsoft's documentation to get it into working.
'Traditional' deployment workflow
What I typically do to deploy my code (outside CI/CD):
sync Git repository
run composer install
run npm run prod (which is a shorthand for compiling webpack in my case)
Done
There is a really easy approach with a Docker container, where in my Dockerfile I just configure php-apache image with additionally installed Nodejs (w. NPM).
However I would like to find a solution to use Azure's built-in features to configure this deployment. Is it possible?
I can use Windows or Linux Web Apps. No difference for me.
I recommend that you use continuous deployment. For specific operations, you can check the official documentation.
Recommended reason:
As long as it runs successfully locally and continuously deploys through git, the project can be released, and later updates only need to submit code through git.
You can easily view the deployment log in Action in git.
Simple operation and convenient update
Steps:
First, ensure that the project is running normally locally, and create web app services on the portal. (Linux is recommended for the nodejs program, which can avoid many problems caused by dependencies)
According to the official document, in the Deployment Center, select github for release
Check the release information of Action on the official github website and wait for the release to be completed
Note:
If it is a nodejs program or other language program, if the Linux operating system is used, the Startup Command may need to be configured in the Configuration. If the program cannot be accessed normally after release, then try to set npx serve -s (nodejs program, other Language program), and then proceed to restart the webapp.
I've created two pipelines: build and release for Nodejs app.
Here is the link to nodejs app repo: azure web service
Here is the tasks for build pipeline:
Here is the wwwroot folder structure:
So it is look like all required files are present.
Despite that, I'm constantly receiving:
You do not have permission to view this directory or page
I've tried to add web.config file, but it did not help.
I have front end application on same App service Plan and it works, so it is no way that I have bad service plan.
Do you have any suggestions?
Thanks a lot.
I was able to deploy my service only after using nodejs-docs-hello-world starter.
It is looks like web.config is a required file, btw, still did not find any meaningfull documentation for web.config.
Make sure your azure nodejs env support your js syntax (import from ...), in other case use webpack or typescript.
I'have found App Service Editor very helpful if you want to debug your code errors. See section Output.
I had a problem also with nodejs version, despite the fact I choosed node 12 tls during web app creation, I have noticed that my app used node 6 under the hood. So I changed default nodejs version to 10. See here how to do it
Also, I want to thank #Jason Pan for his help.
I am struggling to find the way to have 2 Azure functions in different language(C# and node.js) in Azure functions Project vs 2017.
Is there a way to do that?
Thanks!
Update
This method is invalid for v2 function(runtime ~2) because now it's required to use single language in one function app. See announcement.
So, the 2 project doesn't replace the functions created by first project?
Do you mean that you found some functions are replaced after new project being deployed to Azure?
Normally they won't be replaced unless functions in new project has same function names as ones already deployed.
create Azure Functions in 2 different language(C#, node.js) under one VS project
#Mikhail is right, VS doesn't provide ways for using js Azure function. No template and debug support for now.
But if you just want to run and deploy them together using VS, with no need to debug nodejs function, there's a workaround.
Generally speaking, you have to manually add nodejs function folder structure to VS project as below.
A folder named after your js function includes function.json and xxx.js file. If you have some packages installed by npm, also add package.json and node_modules folder.
function.json, xxx.js and package.json should be set as Copy if newer, so that they can be included in output dir like c# complied dll.
Not need to include node_modules locally, function host will locate them automatically. While after deploying to azure, you need to visit kudu(https://{functionappname}.scm.azurewebsites.net/DebugConsole). Execute npm install in console under wwwroot folder to install packages in package.json.
And some function templates if needed.
I'm working on a website that deploys its custom version of node (x64) that we upload and configure via iisnode.yml. We have a dependency in a binary package (zopfli) that we build locally and deploy as well. So far so good.
The problem is with one of the webjobs we have. It seems like it is always using the x86 version of the node version set in WEBSITE_NODE_DEFAULT_VERSION no matter the value of issnode.yml or the platform I select via the portal.
So my question is:
How can I tell my webjobs to use the same version I specify in iisnode.yml (bin\node.exe)?
The WebJob won't look at iisnode.yml. The simplest solution is to create a run.cmd file in your WebJobs folder, and have it explicitly run what you want. e.g. it could have:
bin\node.exe foo.js
After enabling Application Insights on my MVC web app I see that a file called ai.0.22.8-build00154.js was added to the /Scripts folder (however, it was not included to the .csproj).
In addition I do not see this file referenced anywhere in the project.
When I run the web app I do see data being sent to my Application Insights instance on Azure.
* Question *
Is this javascript file even required?
Note that I do have the script snippet at the end of the section (per App. Insights documentation).
This file is not required. It is included in case you decide to host Application Insights JS SDK yourself and not use the hosted version on CDN (http://az416426.vo.msecnd.net/scripts/a/ai.0.js). The snippet is referencing this version, so in case you decide to host AI JS SDK script yourself, you also need to update the snippet.
It is recommended that you are referencing the version on the CDN as this is the way to get all the latest updates automatically.
Yes I believe it is required, it's the Nuget package. The filename you have up there seems to match up with the package.