I find myself publishing from Visual Studio 2015 an application
- NodeJS
- Express
I want to publish it to Azure and of course using Git Deployment . Everything seems normal, but when running the website from the browser I always get a 403 error.
This doesn't happen when I publish directly via Web Deployment, but that doesn't work for me because I want to leave everything working with continuous integration via Git.
To rule out problems in my application, I have created an application from the template and as it is, it already fails in the same way.
I can't find the error, any ideas about it?
I suspect that I must be missing something in web.config
it but I can't find the subject.
After much back and forth and reporting a bug in the Microsoft/NodeJSTools repository (no definitive answer yet) I managed to understand why it fails and of course find an optimal solution among several possible ones.
Diagnosis
After analyzing the deployment I realized that the site in azure throws a forbidden error because basically the web.config is not loaded in the root and therefore IIS cannot process it, since there are no settings IIS is denying access to any resource.
Even putting the web.config in root later, it would be necessary to make several modifications in the iisnode handler and in the url rewrites configuration
Solution
When creating the solution/project - or even after - you must ensure that the contents of the website are published as roots, that is, do not create additional folders for the project within the solution since the deployment leaves with the complete folder structure.
I had a similar situation to tell the truth this is not the solution but you could get closer to it. If you have not yet activated debugging on your site.
Create a file in the root of your application called IISNode.yml with the following content.
Reboot the site and run this line in your Azure Command Line Tools
For more information you can enter here
How to debug a Node.js web app in Azure App Service
The 403 error means prohibited, usually due to lack of privileges.
The same thing happened to me when I uploaded my node.js app to azure from a gitlab repository that I had on a machine also in azure, and it turned out that the git repository did not have the permissions to be accessed publicly. I suggest you check the access permissions to the repository and just to do your tests leave it in public, that way you can rule out that this is the error.