[英]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
中的虛擬應用程序和目錄)是否相同。
Save
並Publish
應用程序。
現在 select 第二個 Web 應用程序並繼續使用導入配置文件發布相同的步驟。
部署 Web Apps 文件夾結構
在這種情況下,這兩個應用程序都可以使用以下 URL 的Ex 訪問:
https://nodesample.azurewebsites.net/NodejsSample1
https://nodesample.azurewebsites.net/NodejsSample2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.