我正在使用Express创建API并尝试在Azure应用服务上部署。我已成功在默认路径site\wwwroot
上部署并运行它。
它工作正常,但是我想把它部署在一个不同的路径site\backend
上,所以我已经为它设置了路径Map,并部署了完全相同的代码,它给出了一个错误。
我已经删除了site\wwwroot
中的代码,认为这可能是因为web.config
重复和相同的结果。我也重新启动了应用程序服务,仍然没有工作。
有什么办法可以解决这个问题吗?
错误
路径Map
应用程序设置
SCM_DO_BUILD_DURING_DEPLOYMENT=true
WEBSITE_NODE_DEFAULT_VERSION=~16
Web配置
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- 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 -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{PATH_INFO}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>
3条答案
按热度按时间v1l68za41#
我可以在Azure应用服务中的Site文件夹下部署多个应用。请按照以下步骤操作。
/
的虚拟路径和带有site\wwwroot
的物理路径。Exp1
和Exp2
。Virtual Directories
,名称为Exp1
和Exp2
。download Publish Profile
(获取发布配置文件)的选项。Import Profile
。在“浏览”选项中,选择下载的Publish Profile
并继续后续步骤。在发布连接设置中,将站点名称更改为以下内容保存并发布。
对应用程序2(Exp2)重复相同的步骤。您可以看到创建了包含源文件的文件夹
Exp1
和Exp2
,并且wwwroot
文件夹也存在。lnlaulya2#
您可以执行以下步骤:
保存更改并尝试以https://domain/test/api/etc访问您的API
zdwk9cvp3#
为什么您要在Azure中配置多个虚拟机,而您可以创建蓝图或功能并使用它,这看起来像是水平扩展一次配置构建多个。
希望这对你有帮助:)