0

I have never used Azure before and I followed the following tutorial: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs#create-a-project-zip-file

I am getting a permissions error when trying to deploy a simple app on Azure made in Node.js. I have tried reuploading multiple times but I get the same error every time. I am using a Free Trial of Azure.

Here is package.json and web.config

PACKAGE.JSON:

{
  "name": "oslo-solutions",
  "version": "1.0.0",
  "description": "",
  "main": "scripts.js",
  "scripts": {
    "test": "karma start karma.conf.js",
    "build": "webpack --mode development",
    "start": "webpack-dev-server --open",
    "lint": "eslint src/*.js",
    "jinit": "./node_modules/.bin/jasmine init",
    "npminit": ""
  },
  "repository": {
    "type": "git"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.2",
    "bootstrap": "^4.0.0",
    "express": "^4.16.3",
    "jquery": "^3.3.1",
    "lodash": "^4.17.5",
    "popper.js": "^1.14.1"
  },
  "homepage": "/",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.3",
    "babel-preset-es2015": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "css-loader": "^0.28.10",
    "dotenv-webpack": "^1.5.5",
    "eslint": "^4.18.2",
    "eslint-loader": "^2.0.0",
    "html-webpack-plugin": "^3.0.6",
    "jasmine": "^3.1.0",
    "jasmine-core": "^2.99.0",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-jquery": "^0.2.2",
    "karma-webpack": "^2.0.13",
    "style-loader": "^0.20.3",
    "uglifyjs-webpack-plugin": "^1.2.2",
    "webpack": "^4.0.1",
    "webpack-cli": "^2.0.11",
    "webpack-dev-server": "^3.1.1"
  }
}

WEB.CONFIG:

<configuration>
  <system.webServer>

    <!-- indicates that the index.js file is a node.js application 
    to be handled by the iisnode module -->

    <handlers>
      <add name="iisnode" path="scripts.js" verb="*" modules="iisnode" />
    </handlers>

    <!-- adds index.js to the default document list to allow 
    URLs that only specify the application root location, 
    e.g. http://mysite.antarescloud.com/ -->

    <defaultDocument enabled="true">
      <files>
        <add value="scripts.js" />
      </files>
    </defaultDocument>

  </system.webServer>
</configuration>
Zahid Faroq
  • 335
  • 1
  • 7
babycoder
  • 184
  • 1
  • 2
  • 17
  • did you use the cli solution or going to the website – Neville Nazerane Jul 21 '18 at 03:19
  • if you have located your website inside portal.azure.com, you can check if your files are setup right – Neville Nazerane Jul 21 '18 at 03:20
  • @Neville Nazarane: Yes, my files are all showing up in portal.azure.com. I showed it to someone else too and they said there was no reason why it shouldn't work so I am thinking there could be something missing in my code. – babycoder Jul 21 '18 at 03:37
  • not used node.js before, but if you can do a cli based build, you can try it in command prompt – Neville Nazerane Jul 21 '18 at 03:38
  • @Neville Nazarane: I did use an Azure cli based build. I followed the tutorial in this link: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs#create-a-project-zip-file – babycoder Jul 21 '18 at 03:46
  • not the azure cli. when you go to portal.azure.com. open your resource, you can search for command line. here you can use command prompt to your web app. – Neville Nazerane Jul 21 '18 at 04:01
  • @Neville Nazarane: What do I type in Command Prompt to give me permission to view my app and get rid of this error: "You do not have permission to view this directory or page."? – babycoder Jul 21 '18 at 04:10
  • @babycoder Any progress now? – Jay Gong Jul 26 '18 at 07:12
  • @Jay Gong: I was able to get it deployed properly but then my button stopped working. Thank you for your help in getting the app up on Azure. – babycoder Jul 27 '18 at 17:32

2 Answers2

3

I followed this sample node.js app: nodejs-docs-hello-world and deploy it to azure.It works fine,please refer to web.config file:

<?xml version="1.0"?>
<configuration>
  <system.web> 
    <compilation batch="false" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="scripts.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="scripts.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

I suggest you navigating to the KUDU url: https://<your app name>.scm.azurewebsites.net/DebugConsole and go to site\wwwroot to check if the files are contained within a directory.

Or discard zip deploy temporarily, just drag the local files directly to the d:home\site\wwwroot directory and try again.

enter image description here

For more solutions, please refer to the threads as below:

1.Getting error after pushing to Windows Azure: You do not have permission to view this directory or page

2.https://github.com/Azure-Samples/nodejs-docs-hello-world/issues/9

Hope it helps you ,any concern please let me know.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32
0

To know the actual error message, turn on the application logging under App Service Log. Save the changes.

Then go to Log Stream Tab, after the connection is succesfull. reload the website so that you can check the actual error of the website.

If it's a 500.19 Internal Server error, then it could be any configuration error in web.config.In my case web.config looked fine. the reason for the internal server error could be unable to load referenced assembly as well.

It's good practice to publish the code in release mode and deploy the website in the azure app service. Bcz we can figure out the issue like reference errors while publishing and resolve them.

I hope sharing my knowledge helped you!