30
votes

I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem:

You do not have permission to view this directory or page.

I did a git master push to azure and the deployment was successful. I also turned on the failed request tracing but nothing shows up but the above statement.

Any ideas on how to troubleshoot this?

9
thank you for your reply, yesDasBoot
Have you deployed your main node file as server.js?AvkashChauhan
I don't understand why this is still an issue in 2019....pcnate
... and still in 2020dbinott
I tried to host an Express NodeJS basic app on Windows App Service. It failed. Then I chose Linux, it worked like a charm.AwsAnurag

9 Answers

20
votes

I just tested that if you don't deploy your main node.js file as server.js you will get this error because the web.config is specifically looking for server.js as below:

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

To further troubleshot this issue you can access the website over FTP as described here.

11
votes

AvkashChauhan's answer did lead me in the right direction but I also had to add proper rewriting rules. Here is my complete web.config

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

I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users:

@Html.Action("GetMenu", "Users")  

For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous:

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Login(LoginModel model, string returnUrl)
    {

My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this:

@if (User.Identity.IsAuthenticated)
{
     @Html.Action("GetMenu", "Users")
}
3
votes

The azure tools have changed a lot since this question.

I recommend people using the azure-cli. But funny enough I actually don't use it after I have used it once to create a site.

What I use now is just the ability to push (git) directly to a remote that is named azure, and the cli is setting that up for you.

But if you don't want to install the cli you can essentially just add the remote repo (your site) manually, like this:

git remote add azure https://<site-or-appservice-name>.scm.azurewebsites.net/<site-or-appservice-name>.git

As you would with every other git remote.

2
votes

Not specific to node.js but updating in case it helps others facing this issue for a regular web application. This can also happen if the index.html file is not present or is not found because it is in a sub-directory

0
votes

I just came across this issue and in my case it was the ipSecurity configuration that was causing the issue. Just hd to go and change the allowUnlisted to true.

 <security>
   <ipSecurity allowUnlisted="false"> 
 </security>
0
votes

Simple configuration, in the azure portal go to your web app -> All settings -> application settings, under default documents add the specific name of your document which you want to view, wait for it to update, then refresh your azure link.

0
votes

I had the same error message after a git push from a local repository.

Solved it by opening the Azure dashboard:

Web app / App deployment / deployment source

and selecting local git repository as deployment source

0
votes

You need to move your server.js file to your root app folder.