0

My requirement is simple.

I already have an one azure app service (https://<app_service>.azurewebsites.net/) and I hosted a NodeJs Web API app under that above mentioned app service. It worked fine when calling the API with specified app service URL(https://<app_service>.azurewebsites.net/).

My virtual path and physical path of the application is like in below image.

virtual path and physical path image

And this is my NodeJS web API app 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>

And this is my 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);
});

Now, I want this same NodeJS Web API application with another virtual path with same azure app service.

For e.g.,

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

new virtual path

Is this possible to achieve? If so, could you please tell me how to achieve this.

Thanks in advance!

  • Yes, It is possible to deploy multiple apps under same app service plan. Working on it will let you know. – Harshitha Aug 22 '22 at 06:22

1 Answers1

0

It is possible to deploy Multiple Web Apps under same App service by using Import Profile and Adding Virtual Directories in Azure Portal

Check the below workaround

  • Created an App service with Runtime stack Node.

  • In the newly created app service add the virtual applications under Configuration => Path Mappings Section enter image description here

  • In the Overview Section of the App service, click on Get Publish Profile enter image description here

  • In Visual Studio created two NodeJS Web Applications enter image description here

  • Right click on the first web app and click on publish enter image description here

  • Browse and select the PUBLISHSETTINGS file downloaded from Azure Web App from portal. enter image description here

  • Make sure that you are giving the site name as same. Here it is NodeSample.

  • Check and verify the name in both places (Virtual Applications and directories in Path Mappings and in Publish Settings) are same.

  • Save and Publish the App.

  • Now select the second Web App and Continue the same steps to publish using Import Profile.

Deployed Web Apps folder structure

enter image description here

In this case Both the Apps are accessible by using the below URL's Ex:

https://nodesample.azurewebsites.net/NodejsSample1
https://nodesample.azurewebsites.net/NodejsSample2
Harshitha
  • 3,784
  • 2
  • 4
  • 9