Azure: "You do not have permission to view this directory or page - node.js

I have created a node.js application in Visual Studio 2015 using the Azure SDK 2.7 and the Node.js Tools.
I have successfully set up CI with BitBucket in my web app and I can see that changes to the repository do indeed trigger a build and deploy.
However, the page I reach (http://ftct.azurewebsites.net/) complains: You do not have permission to view this directory or page.
I have specified a default file (kinda) in my node.js by using: app.get('/', routes.index);
So trying to navigate directly to this file, http://ftct.azurewebsites.net/signin.html, yields a different error: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I configured the app to run on port 1337 in Visual Studio, but using this port doesn't overcome the problem. Trying to navigate to a ported address yields a timeout.
Any ideas?

I had the same issue,
you need web.config, package.json, server.js at the root
web.config:
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</configuration>
in package.json you need to have:
...
"scripts": {
"start": "node server"
},
...
and in your server.js make sure that you set the server port number to
process.env.PORT || 1337;

Edit: Try creating "Node JS Empty Web App" from the gallery at https://portal.azure.com and compare the web.config and the site with what you have. It's possible that you're missing some config settings.
Previous answer: first off, only ports 80 and 443 are available in Azure Web Apps (the new name of Azure Websites). So port 1337 will not work. Reconfigure your app to run on port 80 or 443. Regarding the permission issue, do you have App Service Authentication enabled? Make sure that is disabled, by editing the Web App's application settings as below.

You can try to create a instance of "Node JS Empty Web App" from the Gallery at the old portal http://manage.windowsazure.com, see below.
Then, doing the set up deployment from source control at the quick glance of the web app dashboard page to deploy your web app.
Now, browse the web app http://<app-name>.azurewebsites.net that works fine.

You're probably missing the web.config file which is required if iisnode is used to run node processes behind iis or iis express.
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config

In my case, I got this error when using ZipDeploy: please be sure to compress files within the root folder, so that the Node.js files could be listed on Kudu at the a base level, instead of one folder more. Thanks to mike-urnun-msft.

Also when you deploy the zip file via the azurewebsites.net/ZipDeployUI, make sure that you see the files being unzipped on the /wwwroot level.
If the files show up under /wwwroot/your-app-folder/ you may get this permission issue. I took a long time to figure this out! Hope it helps.

My situation is similar but slightly different. I was working on the Facebook Messenger Platform "Setting Up Your Webhook" documentation steps.
localhost was working just fine, but upon deployment, it would simply say what others have noted.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
my final package.json looked like it, and it worked.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
I think, the issue boils down to the way facebook provided the demo code. The demo code simply does not have everything needed to deploy specifically on azure.
I have put my final code here (it can be used as a starter i think for another person who is running into deployment issues).
Also, interestingly enough, others have suggested web.config, but I did not need it really.
https://github.com/Jay-study-nildana/FBMessengerWebHook

The problem is most likely the wrong folder was pushed up. For an ASP.NET server the root folder must have the index.html file.
Angular Specific
Before deploying issue ng build --prod in your dev environment.
This creates a 'dist' folder in the solution.
Next open Visual Studio Code to the first folder in the 'dist' folder.
In this case the folder name was 'resume' which just so happened to be the Angular project name. Note that the index.html file is in this folder.
Note you know you are on the right track when pushing this up because this folder is small and it finishes quickly.
I use the Azure tools plugin for VSCode, it simply prompts me for the proper subscription (your Microsoft account) and from there just click the up arrow for the upload!

Related

Running Storybook in Azure App Service (not Static Storybook)

I have Storybook running locally without issue. I am able to start it with the npm run storybook command. However, when I try to host Storybook in an Azure App Service, it fails to load with the following error after running the npm run storybook:
You do not have permission to view this directory or page.
I tried building storybook into the static files and setting the App Service default document to index.html, but we require using the storyStoreV7 option which doesn't work in static builds. If the static files worked with storyStoreV7 I would not use an App Service and just build the static files: https://github.com/storybookjs/storybook/issues/16967
Since Storybook doesn't have a traditional start page (from what I can see) versus a node app running a server.js and I want to run the full Storybook with the node modules in my Azure App Service node app, how do I get it to load?
When I run the npm run storybook command in Storybook, it acts like it is starting the app, but again, nothing shows at the https://mystorybook.azurewebsites.net URL except the earlier mentioned error.
Here I was able to deploy the storybook-react app by deploying using local git and adding the starting commands
you can set deployment strategy using the deployment center tab in the azure portal just push the local git repro to the link provided in the portal
output:
After digging in more, it kept erroring on a fetch to stories.json so I needed to change my web.config to this:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
This is per: https://learn.microsoft.com/en-us/archive/blogs/africaapps/how-to-serve-static-json-files-from-a-windows-azure-website
With this in place it can read stories.json and render storybook. I also needed to have index.html as a default document on the App Service as that is the start point of the static build (I extract the static-storybook files to the wwwroot of the Azure App Service).
This does leverage the static build, and resolves the issue as stories.json not getting loaded was the issue.

gcloud Nodejs http 500 error cannot find server.js in workspace [more detailed repost]

I am new to google cloud and so I deployed a Nodejs app using the tutorial. Everything worked just fine, here is my file structure (I didn't make the my-nodejs-service folder):
app.yaml
server.js
package.json
I deployed it, everything was fine. So then I tried to make it look like this:
mySite/
server.js
package.json
app.yaml
public/
site contents
I just forked a github repo, deployed it, and it didn't work. By that I mean the site didn't load! I checked the logs, and here was what appeared:
Error: Cannot find module '/workspace/server.js'
at Function.Module._resolveFilename (loader.js:880)
at Function.Module._load (loader.js:725)
at Function.executeUserEntryPoint (internal/modules/run_main.js:72)
"GET / HTTP/1.1" 500
listening on port 3000
It said it couldn't find the server.js file. Was it because I moved the code into the folder? I deployed it on the current working directory being the folder mySite.
package.json (Im only including the scripts part, it other stuff such as the dependencies):
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
}
}
Other things I tried:
deploying with app.yaml at the end of the deployment command
Using path.join()
Deploying multiple times
Other info:
I checked the logs and I got this:
"GET / HTTP/1.1" 500 - - "Web browser agent info in here"
Another showed:
i This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
And another log said:
!! Process was terminated because the request deadline was exceeded. Please ensure that your HTTP server is listening for requests on 0.0.0.0 and on the PORT environment variable. (Error code 123)
App Engine uses a set of conventions in order to be able to deploy and run code successfully. As you've seen, you can't necessarily take an arbitrary web server solution and deploy it successfully.
Please include more details about specific steps you take. For example, you say "I .. deployed it". It would be useful for you to include the command that you used and any immediate errors that were thrown to provide readers with more context when helping answer your question. It's unclear to me from which directory you attempted to deploy the mySite example but I assume from within mySite.
The first error Cannot find module '/workspace/server.js' results because App Engine builds your code using Cloud Build and Cloud Build (by default) puts your code into a /workspace directory on the build VM. It's not very user-friendly, but it was unable to find server.js and, because your package.json specifies node server.js, it needs it.
Another statement that gives me pause is listening on port 3000. I'm not very familiar with the Node.JS runtime but generally App Engine expects web server's to either listen on port :8080 or provide an environment variable that specifies the port, In your tutorial, this is explained: "process.env.PORT is not set, port 8080". That's probably (!?) another issue.
Lastly, you may (I think you probably don't) need to explicitly reference the public subdirectory (unsure) in order to ensure that it's available at runtime.

How to use Node -r flag inside npm scripts on Azure App Service

I am running a node site on an Azure App Service but it won't start with the following line in my package.json scripts.
"scripts": {
...
"serve": "node -r dotenv-azure/config dist/server.js",
...
},
The -r flag is required to preload environment variables using dotenv-azure, as per their own instructions... https://www.npmjs.com/package/dotenv-azure
it works absolutely fine on localhost (Windows), it loads the config before starting the server. On Azure App service (windows) however it fails to start the server and I get a 503 error after starting it.
I have tried switching on application logging but because it can't even start the server I get nothing in the logs.
After add httpplatformhandler in web.config file, it works for me. You can download my sample code from github. You will find my web.config file.
Test Steps:
1. Create a sample code.
2. Create .env file.
3. Test result in local.
4. Deploy by git.
After deployed, it also has some error, we should add web.config to solve it.
After add web.config file ( With httpplatformhandler):

React Builds- Which files go on the server? Why isn't my project deploying?

Goal: I have created the start of a React project and wish to test it on my server (hosted by goDaddy, uploading via cPanel). My app works fine in Development Mode.
Question: I have ran npm build which has created a build folder, but what files am I supposed to upload to my server? I tried putting the entire contents of the build folder on, but it still says the site is not launched. Is this because there is no index.html file generated? Currently my build folder contains: assets.json, LICENSE.txt, package.json, server.js, yarn.lock, chunks/ and public/. Is there supposed to be an html file generated? Or should these files be sufficient to deploy the website given that it works in development mode?
Thanks for bearing with me, this is the first time I have tried to deploy a React App and likely have several fundamental misunderstandings of how it works. Also if anyone is willing to chat for several minutes so I can ask a few questions about my project and react let me know - much appreciated!
Hello
Dear,
If you can try to change your package.json file and add ("homepage": "http://yourDomain/",) like this
"version": "0.1.0",
"homepage": "yourDominUrl",
Like
"homepage": "http://yourDomain/",
and
build again
npm run build
and the build folder is only should be uploaded file
Your answer is much more simple than appears: Just run npm run build, then just upload that whole folder to your GODADDY server. Importantly, you must place your index.html (or app-name.html) directly on the / public path defined by your URL's DNS. So, Top-level has your single entry point index.html that points to folder build/ to get your xyx.main.js and the xyz.main.css ...
and that's it! easy as pie

How to initialize a koa node.js app application on IISNode (Azure WebSites)

We are currently moving a self-hosted koa app to IISNode on Azure WebSites..
In self-hosting, we initiallize the application by calling
node --harmony ./bin/application
Requests then go to ./index.js.
However we could not find how to setup IISNode to call "bin/application" at initialization time.
Any ideas?
Thanks
Not sure this is the same scenario, but I ran into something that sounds like this when express.js started using ./bin/www as the entry point for express.js apps. Initially it broke everything, but now we look for the "scripts" entry in the package.json to tell Azure how to configure IISNode for the application. For express, it generates a "scripts" entry that looks like this:
"scripts": {
"start": "node ./bin/www"
},
When Azure sees this, it generates a web.config on the server that uses ./bin/www for the entry point.
So... I'd say first off, try adding a "scripts" entry to the package.json that points to your ./bin/application file, and try deploying that to Azure. Hopefully that 'just works'. If it doesn't, try adding a web.config to the root of your application, using https://gist.github.com/Blackmist/8677359708fd30779c77 as the contents. This should point IISNode to the ./bin/application file as the entrypoint, and is what Azure Websites should automatically generate when it sees the "scripts" entry in the package.json file.
The other problem you'll run into is using Node.js v0.11.13, which I don't believe is included in Azure websites by default, and passing the --harmony switches. http://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/ has a section on including a version of node.js as part of your website. In the iisnode.yml file, you'd want to have a line similar to the following:
nodeProcessCommandLine: d:\home\site\wwwroot\bin\node.exe --harmony
I believe this should make this work.
You can setup custom deployment scripts for Azure Websites.
This blog post contains details on how to use it:
http://blog.amitapple.com/post/38417491924/azurewebsitecustomdeploymentpart1/#.VBcrnPldXIc

Resources