iis 如何在Azure应用服务中配置多个虚拟应用程序?

sdnqo3pr  于 2022-11-12  发布在  其他
关注(0)|答案(3)|浏览(174)

我正在使用Express创建API并尝试在Azure应用服务上部署。我已成功在默认路径site\wwwroot上部署并运行它。
它工作正常,但是我想把它部署在一个不同的路径site\backend上,所以我已经为它设置了路径Map,并部署了完全相同的代码,它给出了一个错误。
我已经删除了site\wwwroot中的代码,认为这可能是因为web.config重复和相同的结果。我也重新启动了应用程序服务,仍然没有工作。
有什么办法可以解决这个问题吗?

错误

路径Map

应用程序设置

  1. SCM_DO_BUILD_DURING_DEPLOYMENT=true
  2. WEBSITE_NODE_DEFAULT_VERSION=~16

Web配置

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. This configuration file is required if iisnode is used to run node processes behind
  4. IIS or IIS Express. For more information, visit:
  5. https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
  6. -->
  7. <configuration>
  8. <system.webServer>
  9. <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
  10. <webSocket enabled="false" />
  11. <handlers>
  12. <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
  13. <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
  14. </handlers>
  15. <rewrite>
  16. <rules>
  17. <!-- Do not interfere with requests for node-inspector debugging -->
  18. <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
  19. <match url="^server.js\/debug[\/]?" />
  20. </rule>
  21. <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
  22. <rule name="StaticContent">
  23. <action type="Rewrite" url="public{PATH_INFO}"/>
  24. </rule>
  25. <!-- All other URLs are mapped to the node.js site entry point -->
  26. <rule name="DynamicContent">
  27. <conditions>
  28. <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
  29. </conditions>
  30. <action type="Rewrite" url="server.js"/>
  31. </rule>
  32. </rules>
  33. </rewrite>
  34. <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
  35. <security>
  36. <requestFiltering>
  37. <hiddenSegments>
  38. <remove segment="bin"/>
  39. </hiddenSegments>
  40. </requestFiltering>
  41. </security>
  42. <!-- Make sure error responses are left untouched -->
  43. <httpErrors existingResponse="PassThrough" />
  44. <!--
  45. You can control how Node is hosted within IIS using the following options:
  46. * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
  47. * node_env: will be propagated to node as NODE_ENV environment variable
  48. * debuggingEnabled - controls whether the built-in debugger is enabled
  49. See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
  50. -->
  51. <!--<iisnode watchedFiles="web.config;*.js"/>-->
  52. </system.webServer>
  53. </configuration>
v1l68za4

v1l68za41#

我可以在Azure应用服务中的Site文件夹下部署多个应用。请按照以下步骤操作。

  • 在Azure门户中创建具有运行时堆栈节点的应用服务。
  • 默认情况下,将创建带有/的虚拟路径和带有site\wwwroot的物理路径。
  • 在VS中,创建2个新的Express应用程序,并将其命名为Exp1Exp2
  • 在Azure门户中,添加新的Virtual Directories,名称为Exp1Exp2

  • 请确保应用程序名称和虚拟路径名称相同。
  • 在Azure应用服务=〉概览中,您将找到download Publish Profile(获取发布配置文件)的选项。

  • 在VS中,右键单击要部署的项目文件夹(Exp1)并选择Import Profile。在“浏览”选项中,选择下载的Publish Profile并继续后续步骤。

在发布连接设置中,将站点名称更改为以下内容保存并发布。

对应用程序2(Exp2)重复相同的步骤。您可以看到创建了包含源文件的文件夹Exp1Exp2,并且wwwroot文件夹也存在。

展开查看全部
lnlaulya

lnlaulya2#

您可以执行以下步骤:

  • 将后端文件夹放置在“站点”内
  • 打开应用程序服务配置
  • 选择路径Map-〉+添加新虚拟目录或应用程序
  • 给予如下所示名称和路径:

保存更改并尝试以https://domain/test/api/etc访问您的API

zdwk9cvp

zdwk9cvp3#

为什么您要在Azure中配置多个虚拟机,而您可以创建蓝图或功能并使用它,这看起来像是水平扩展一次配置构建多个。
希望这对你有帮助:)

相关问题