It's quite easy to host multiple ASP.NET projects on a single Azure Web Role (tutorial) but is it possible to use a single Web Role to host both ASP.NET and node.js projects?
Asked
Active
Viewed 1,313 times
1 Answers
4
Yes this is possible, using 2 different solutions:
You can have a background startup task that runs node.exe with the required parameters. For your ASP.NET application nothing changes, the only thing you'll need to do is include the node files in that project and reference that directory when launching node.exe
Use iisnode. This allows you to run your node code through an IIS HttpModule which brings some extra nice features with it (quoting Tomasz Janczuk):
- Process management. The iisnode module takes care of lifetime management of node.exe processes making it simple to improve overall reliability. You don’t have to implement infrastructure to start, stop, and monitor the processes.
- Scalability on multi-core servers. Since node.exe is a single threaded process, it only scales to one CPU core. The iisnode module allows creation of multiple node.exe processes per application and load balances the HTTP traffic between them, therefore enabling full utilization of a server’s CPU capacity without requiring additional infrastructure code from an application developer.
- Auto-update. The iisnode module ensures that whenever the node.js application is updated (i.e. the script file has changed), the node.exe processes are recycled. Ongoing requests are allowed to gracefully finish execution using the old version of the application, while all new requests are dispatched to the new version of the app.
- Access to logs over HTTP. The iisnode module provides access the output of the node.exe process (e.g. generated by console.log calls) via HTTP. This facility is key in helping you debug node.js applications deployed to remote servers.
- Side by side with other content types. The iisnode module integrates with IIS in a way that allows a single web site to contain a variety of content types. For example, a single site can contain a node.js application, static HTML and JavaScript files, PHP applications, and ASP.NET applications. This enables choosing the best tools for the job at hand as well progressive migration of existing applications.
- Minimal changes to node.js application code. The iisnode module enables hosting of existing HTTP node.js applications with very minimal changes. Typically all that is required is to change the listed address of the HTTP server to one provided by the iisnode module via the process.env.PORT environment variable.
- Integrated management experience. The iisnode module is fully integrated with IIS configuration system and uses the same tools and mechanism as other IIS components for configuration and maintenance.
In addition to benefits specific to the iisnode module, hosting node.js applications in IIS allows the developer to benefit from a range of IIS features, among them:
- port sharing (hosting multiple HTTP applications over port 80)
- security (HTTPS, authentication and authorization)
- URL rewriting
- compression
- caching
- logging

Jack M.
- 30,350
- 7
- 55
- 67

Sandrino Di Mattia
- 24,739
- 2
- 60
- 65
-
1Thanks for the reply! Do you happen to have an example available for the IISNode-option? I was able to get everything working on the Azure Emulator, but when deployed, the service fails to start. – Mikael Koskinen Oct 24 '12 at 04:16
-
@MikaelKoskinen how did you integrate IISNode with Azure? I've been looking for information on doing exactly this. – Seth Mar 11 '13 at 15:47