繁体   English   中英

是否可以在单个 azure 应用服务中部署多个 Nodejs Web API 应用?

[英]Is there possible to deploy multiple Nodejs Web API App in single azure app service?

我的要求很简单。

我已经有一个 azure 应用服务 (https://<app_service>.azurewebsites.net/) 并且我在上述应用服务下托管了一个 NodeJs Web API。 使用指定的应用服务 URL (https://<app_service>.azurewebsites.net/) 调用 API 时,它工作正常。

我的应用程序的虚拟路径和物理路径如下图所示。

虚拟路径和物理路径图像

这是我的 NodeJS web API 应用程序 web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
  <webSocket enabled="false" />
  
  <handlers>
    <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
  </handlers>
  <rewrite>
    <rules>
      <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
        <match url="^index.js\/debug[\/]?" />
      </rule>

      <rule name="StaticContent">
        <action type="Rewrite" url="public{REQUEST_URI}"/>
      </rule>

      <rule name="DynamicContent">
        <conditions>
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
        </conditions>
        <action type="Rewrite" url="index.js"/>
      </rule>
    </rules>
  </rewrite>

  <security>
    <requestFiltering>
      <hiddenSegments>
        <remove segment="bin"/>
      </hiddenSegments>
    </requestFiltering>
  </security>

  <httpErrors existingResponse="PassThrough" />
</system.webServer>

这是我的 NodeJS web API app index.js

var express = require("express");
var app = express();

app.get("/", function(req, res) {
  res.send("Call from Node API!!!");
});

var port = process.env.PORT || 1660;

var server = app.listen(port, function () {
  console.log("Listening on port %s...", server.address().port);
});

现在,我想要这个相同的 NodeJS Web API 应用程序和另一个具有相同 azure 应用程序服务的虚拟路径。

例如,

(https://<app_service>.azurewebsites.net/nodeapi)

新的虚拟路径

这有可能实现吗? 如果是这样,你能告诉我如何实现这一目标。

提前致谢!

通过在 Azure 门户中使用Import Profile和添加虚拟目录,可以在同一应用服务下部署多个 Web 应用

检查以下解决方法

  • 使用运行时堆栈节点创建了一个应用服务。

  • 在新创建的应用服务中,在Configuration => Path Mappings部分下添加虚拟应用程序在此处输入图像描述

  • 在应用服务的概览部分,单击Get Publish Profile在此处输入图像描述

  • 在 Visual Studio 中创建了两个NodeJS Web Applications在此处输入图像描述

  • 右键单击第一个 web 应用程序,然后单击发布在此处输入图像描述

  • 浏览并 select 从门户网站Azure Web App下载的 PUBLISHSETTINGS 文件。在此处输入图像描述

  • 确保您提供的站点名称相同。 这是NodeSample

  • 检查并验证两个地方的名称(路径映射和Publish Settings中的虚拟应用程序和目录)是否相同。

  • SavePublish应用程序。

  • 现在 select 第二个 Web 应用程序并继续使用导入配置文件发布相同的步骤。

部署 Web Apps 文件夹结构

在此处输入图像描述

在这种情况下,这两个应用程序都可以使用以下 URL 的Ex 访问:

https://nodesample.azurewebsites.net/NodejsSample1
https://nodesample.azurewebsites.net/NodejsSample2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM