更改Azure上NodeJS应用程序的初始文件位置

Changing the initial file location of NodeJS app on Azure

本文关键字:文件 位置 应用程序 Azure NodeJS 更改      更新时间:2023-09-26

我在Azure上有一个用Javascript编写的NodeJS应用程序。app.js在根目录中,在通过Git部署到Azure时自动检测到。

我最近将应用程序转换为带有构建目录的Typescript,所以根文件现在在dist/app.js中。

在VS Code中调试时,我可以很容易地改变launch.json指向新的位置,但是现在当将更改推送到Azure时,它不再工作。

如何为Azure指定启动文件?

您可以修改应用程序根目录中的web.config

修改<handlers>标签:

<handlers>
    <!-- Indicates that the app.js file is a node.js site to be handled by the iisnode module -->
    <add name="iisnode" path="/dist/app.js" verb="*" modules="iisnode"/>
</handlers>

修改修改后的mod:

<rule name="DynamicContent">
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
    </conditions>
    <action type="Rewrite" url="dist'app.js"/>
</rule>