在单个Azure Web角色中混合node.js和ASP.NET项目? [英] Mixing node.js and ASP.NET projects in a single Azure Web Role?

查看:106
本文介绍了在单个Azure Web角色中混合node.js和ASP.NET项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单个Azure Web角色上托管多个ASP.NET项目非常容易(

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?

推荐答案

是的,可以使用两种不同的解决方案:

Yes this is possible, using 2 different solutions:

  1. 您可以有一个后台启动任务,该任务使用必需的参数运行node.exe.对于您的ASP.NET应用程序,没有任何变化,您唯一需要做的就是将节点文件包含在该项目中,并在启动node.exe时引用该目录.

  1. 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

使用 iisnode .这样,您就可以通过IIS HttpModule运行节点代码,而IIS HttpModule则带来了一些额外的出色功能(引用Tomasz Janczuk):

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):

  • 进程管理..iisnode模块负责node.exe进程的生命周期管理,从而可以轻松提高整体可靠性.您无需实施基础架构即可启动,停止和监视流程.
  • 在多核服务器上的可伸缩性.由于node.exe是单线程进程,因此只能扩展到一个CPU内核.iisnode模块允许在每个应用程序中创建多个node.exe进程,并在它们之间的HTTP流量进行负载平衡,从而可以充分利用服务器的CPU容量,而无需应用程序开发人员提供额外的基础结构代码.
  • 自动更新..iisnode模块可确保每当更新node.js应用程序(即脚本文件已更改)时,都会回收node.exe进程.允许进行中的请求使用旧版本的应用程序正常完成执行,而所有新请求均分派到新版本的应用程序.
  • 通过HTTP访问日志. iisnode模块可通过HTTP访问node.exe进程的输出(例如console.log调用生成).该功能是帮助您调试部署到远程服务器的nod​​e.js应用程序的关键.
  • 与其他内容类型并排..iisnode模块与IIS集成在一起,允许单个网站包含多种内容类型.例如,一个站点可以包含一个node.js应用程序,静态HTML和JavaScript文件,PHP应用程序以及ASP.NET应用程序.这样,您就可以为手头的工作选择最佳工具,并逐步迁移现有应用程序.
  • 对node.js应用程序代码的最小更改..iisnode模块允许通过很小的更改来托管现有HTTP node.js应用程序.通常,所需要做的就是通过process.env.PORT环境变量将HTTP服务器的列出地址更改为iisnode模块提供的地址.
  • 综合管理经验. iisnode模块与IIS配置系统完全集成,并使用与其他IIS组件相同的工具和机制进行配置和维护.除了特定于iisnode模块的优势之外,在IIS中托管node.js应用程序还使开发人员可以从一系列IIS功能中受益,其中包括:
    • 端口共享(通过端口80托管多个HTTP应用程序)
    • 安全性(HTTPS,身份验证和授权)
    • URL重写
    • 压缩
    • 缓存
    • 记录
    • 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

      这篇关于在单个Azure Web角色中混合node.js和ASP.NET项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆