如何在 Azure WebApps 上部署多个应用程序
How to Deploy Multiple Apps on Azure WebApps
我有两个不同的应用程序,我想将它们部署在同一个 Azure WebApp 上,如下所示:
webapp.azurewebsites.net/api/ <-- run the Java REST API here
webapp.azurewebsites.net/site/ <- put the Angular2 app here
问题
这两个应用程序都部署在服务器上,但目前我只能像这样获得 REST API 运行 web.config
:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false"/>
<conditions>
<add input="{HTTPS}" pattern="off"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-jar D:\home\site\wwwroot\webapps\rest-api.war">
</httpPlatform>
</system.webServer>
</configuration>
但我无法访问服务器上的 Angular2 应用程序,而且我找不到如何同时配置 Java 应用程序和 Angular2 应用程序的文档。
我也尝试通过 Application settings
下 Azure 仪表板的 Virtual applications and directories
设置来实现这一点 - 但它没有用,我找不到关于如何实现的合适文档这个,或者如果这甚至可以通过设置 Virtual applications and directories
.
我尝试移动 Angular2 站点,但无法配置服务器,以便在 Java 应用程序处于 运行 时可以访问 Angular2 应用程序。
问题
有人能给我指点一份关于如何实现这一点的好文档,或者详细描述部署过程(关于配置,例如来自 Azure 仪表板的 Application settings
和 web.config
文件)?
关于您回答的第二部分,在调查该主题时,我发现此博客 post 是对仪表板中的应用程序设置如何与 Web.config 文件交互的最佳解释:
https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
特别是 -
If the application setting(s) happen to already exist in your web.config file, Windows Azure Web Sites will automatically override them at runtime using the values associated with your website.
因此 Azure 门户中的“应用程序设置”选项卡将优先于您的 web.config 值。
根据我的经验,我认为在 Azure WebApps 上部署多个应用程序的最佳方法是为您的 Azure Webapp 设置 Virtual applications and directories
或 Application Settings
,请参见下图。
作为参考,请参考SO线程的回答Add virtual directory to existing website on Azure。
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 WebApp 上,如下所示:
webapp.azurewebsites.net/api/ <-- run the Java REST API here
webapp.azurewebsites.net/site/ <- put the Angular2 app here
问题
这两个应用程序都部署在服务器上,但目前我只能像这样获得 REST API 运行 web.config
:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false"/>
<conditions>
<add input="{HTTPS}" pattern="off"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-jar D:\home\site\wwwroot\webapps\rest-api.war">
</httpPlatform>
</system.webServer>
</configuration>
但我无法访问服务器上的 Angular2 应用程序,而且我找不到如何同时配置 Java 应用程序和 Angular2 应用程序的文档。
我也尝试通过 Application settings
下 Azure 仪表板的 Virtual applications and directories
设置来实现这一点 - 但它没有用,我找不到关于如何实现的合适文档这个,或者如果这甚至可以通过设置 Virtual applications and directories
.
我尝试移动 Angular2 站点,但无法配置服务器,以便在 Java 应用程序处于 运行 时可以访问 Angular2 应用程序。
问题
有人能给我指点一份关于如何实现这一点的好文档,或者详细描述部署过程(关于配置,例如来自 Azure 仪表板的 Application settings
和 web.config
文件)?
关于您回答的第二部分,在调查该主题时,我发现此博客 post 是对仪表板中的应用程序设置如何与 Web.config 文件交互的最佳解释: https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
特别是 -
If the application setting(s) happen to already exist in your web.config file, Windows Azure Web Sites will automatically override them at runtime using the values associated with your website.
因此 Azure 门户中的“应用程序设置”选项卡将优先于您的 web.config 值。
根据我的经验,我认为在 Azure WebApps 上部署多个应用程序的最佳方法是为您的 Azure Webapp 设置 Virtual applications and directories
或 Application Settings
,请参见下图。
作为参考,请参考SO线程的回答Add virtual directory to existing website on Azure。
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.