azure - 是否可以在一个 Web 应用程序中拥有 2 个 ASP.NET Core 站点?

标签 azure azure-web-app-service

一个应用服务中是否可以有 2 个 ASP.NET Core Web API 应用?

我知道最好将这 2 个站点放在单独的应用服务中,但我们的用例有点独特。

我们尝试添加第二个站点,以便使用 applicationInitialization 功能在应用程序启动和向应用程序服务负载均衡器提供实例之间引入延迟。 我可以对此进行更详细的介绍,但我现在想要的是附加一个额外的网站,applicationInitialization 可以调用该网站来延迟启动过程。

我已经尝试过:

Folder structure: 
  /mySite
  /mySite2
  web.config

Folder structure: 
  /mySite2
  mySite.dll
  web.config

各自的 web.Config 如下所示:

<?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>

<?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>

最佳答案

是的。您可以在一个 Web 应用程序上使用 virtual directory. 来运行两个应用程序。

来自文档:

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.

关于azure - 是否可以在一个 Web 应用程序中拥有 2 个 ASP.NET Core 站点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58508658/

相关文章:

wcf - 使用 WCF 服务将 mschart 添加到 Windows Azure 应用程序时出现的问题

sql-server - 使用 ADF Pipeline 中的自定义事件从 OnPrem SQL Server 复制到 DocumentDB

azure - 将对 Azure 静态 Web 应用程序的访问限制为单个租户

azure - 如何使用 Azure Powershell 检索应用程序系统分配的标识对象 ID

azure - Windows Azure 网站 - 获取实例标识符

azure - 部署Azure Function时ConnectionString为null

azure - 两个应用程序的相同表、通知中心和服务器

azure - 前几个请求返回 500 Unable to Download OpenID Connect Configuration,然后成功

node.js - index.js 文件中的 Azure Node.js 内部服务器错误

azure - 更新 web.config 以添加针对 Azure 应用服务的 Azure DevOps 发布管道中特定环境的重写规则