简体   繁体   中英

How To Deploy NodeJS REST API To AZURE Cloud

I'm trying to deploy my nodejs rest api application to my azure cloud, but i fail again and again.

I get HTTP 500 response.

"The page cannot be displayed because an internal server error has occurred."

My AZURE FTP (What I Uploaded) :

在此处输入图片说明

web.config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <webSocket enabled="false" />
    <handlers>
      <add name="iisnode"
           path="app.js"
           verb="*"
           modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector"
              patternSyntax="ECMAScript"
              stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}"
                 matchType="IsFile"
                 negate="True"/>
          </conditions>
          <action type="Rewrite" url="app.js"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

URLs

Request : localhost/api/user/getcategories/5c141fa7498f3605c8b2cf34

Response :

{
    "success": true,
    "categories": [
        {
            "_id": "5c141fab498f3605c8b2cf35",
            "name": "OTHER"
        }
    ]
}

Request : https://**.azurewebsites.net/api/user/getcategories/5c141fa7498f3605c8b2cf34

Response : The page cannot be displayed because an internal server error has occurred.

If you access your Azure App Service pane for the web app, under Development Tools you should have a "Advanced Tools". Select it and then hit "go" to access Kudu.

Kudu Advanced Tools Screenshot

You can then go to the "Debug Console" dropdown to access your preferred shell. From here you should be able to access the server logs and see what errors are being thrown.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM