简体   繁体   中英

Is it possible to have 2 ASP.NET Core sites in one Web App?

Is it possible to have 2 ASP.NET Core Web API apps inside the one App Service?

I understand that it would be better to have the 2 sites in separate App Services, but our use case is a bit unique.

We're trying to add the 2nd site for the purposes of using the applicationInitialization feature to introduce a delay between our app starting and the instance being given to the App Service load balancer. I could go into a lot more detail on this, but what I desire for now is to bolt-on an additional web site that the applicationInitialization can call to delay the startup process.

I've tried:

Folder structure: 
  /mySite
  /mySite2
  web.config

Folder structure: 
  /mySite2
  mySite.dll
  web.config

With respective web.Configs looking like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="mySite" inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\mysite\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
  <location path="mySite2" inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

and

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
  <location path="mySite2" inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

YES. It is possible, you can have two applications on a single web app with a virtual directory.

From docs:

Virtual Directories are supported for Azure Websites. See Configuring Azure Websites for what you can do through the Azure Management Portal. From the Azure Portal, click on the Website and go to Configure, then scroll down to virtual applications and directories (the last config section). Just enter your virtual directory and the physical path relative to the site root and click Save.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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