How to get standard out from a Node.js application in Azure? - node.js

We have a Node.js application with a pretty big codebase that we're trying to deploy to an Azure Web Site. My problem is that when I deploy the app and try to access it, I just get a message saying "The page cannot be displayed because an internal server error has occurred".
According to http://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-debug/ I should be able to configure some settings and have my standard out be logged to a file - well, it's not working. in /LogFiles I can see /git, /html, and /DetailedErrors, but none of these folders contain the stdout logs.
I have deployed the app using Visual Studio. I created a blank Azure project, and manually added all the folders and files I need. I also created an iisnode.yml file that contains the following config:
loggingEnabled: true
devErrorsEnabled: true
logDirectory: ./logs
debugHeaderEnabled: true
The last two lines I added later, the first ones are from the tutorial. I also have a web.config file, the contents of which I haven't really touched.
I've attempted to configure the settings that are available in the Web Sites UI, but I haven't really been able to make any headway. I think currently they are pretty much default.
I'm sorry that I can't provide you with more information. I'm really kind of banging my head against the wall here, since all the tutorials I've found basically state that if I do this and that, everything should work. The problem is, it doesn't. Sad face.
Edit: I should probably add that my server.js is in a folder called /NodeServer. It's not in the root as Azure seems to presume.
Edit2: I deployed a Hello World example and got it to work, but when I try to move the server.js file from the root I can't get it to work anymore.
I've added a tag to the web.config, so that the structure is basically
configuration
location path="NodeServer"
system.webServer
I've also edited my package.json so that it says
"main":"NodeServer/server.js",
"scripts":{
"start":"cd NodeServer && node server.js"
}

If the app is started successfully, you should be able to find the stdout at
D:\home\LogFiles\Application
in Azure Websites, without configuring anything.
But here it looks like an error related to incorrect/missing web.config. The node app may not get launched. You can try:
Publishing your app using git to Azure Websites.
Or if you are familiar with IIS and iisnode, make sure your app works locally with IIS and iisnode. See http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html
Or try publishing an "hello world" node.js app to Azure Websites, take the generated web.config and modify it for your app.
Edit: When you change the location of server.js, you have to change web.config too. The change in web.config is not correct. And package.json is only used as hints to generate web.config during git deployment. To get your "hello world" to work, you can either
In your web.config, replace all "server.js" with "NodeServer/server.js".
Or deploy the modified app using git. Make sure it does not contain the wrong web.config.
Then you can try to get your larger app to work.

Related

Deploying [different-project-folder] instead of selected folder [current-project-folder]. Use "appService.deploySubpath" to change this behavior

I have two projects I'm working on for two separate Web Apps on Microsoft Azure under the same subscription. The first Web App project works fine, but for some reason when I try to deploy my new project to the other Web App, VSCode keeps telling me:
Deploying [first-project-folder] instead of selected folder [current-project-folder]. Use "appService.deploySubpath" to change this behavior.
Even when I change this setting to point to the correct project folder, it does the same thing. Nothing changes. I'm using the Azure App Service extension in VSCode on Windows 10.
I had a similar problem, and it was because I was changing the deploySubpath in the wrong settings.json file. I changed the one in the directory I was trying to deploy and it didn't work.
Try changing settings.json under the root \.vscode.

app_artifact_location when the app is internationalized

I'm working with the new Azure Static Web Apps Preview product, not to be confused with Azure Web Apps.
My Angular 9 app, which runs fine locally, is all set up for internationalization, and one effect of the internationalization is that it drops my index.html into app/catfood/dist/en_US rather than app/catfood/dist.
This is leaving me stuck in terms of how to set the app_artifact_location value in the workflow file. If I leave it at the default value of "dist/catfood" the build gives me this error, which honestly does seem accurate as the index.html isn't going to be there:
Failed to find a default file in the app artifacts folder (dist/congruence-web). Valid default files: index.html,Index.html.
If your application contains purely static content, please verify that the variable 'app_location' in your workflow file (located in .github/workflows) points to the root of your application.
If your application requires build steps, please validate that a default file exists in the build output directory.
But if I change it to the logical "dist/catfood/en_US" I get this error:
The app build failed to produce artifact folder: 'dist/catfood/en_US'. Please ensure this property is configured correctly in your workflow file.
Really not sure what the build system is expecting of me. What should I be using for app_artifact_location? Or am I even tweaking the wrong thing here?
Update: When I deliberately turn off i18n in angular.json, the en_US directory goes away and index.html is found in dist/catfood and everything works great. So basically the problem is "Why does Azure Static Web Apps not understand localized Angular applications?"

HTTP Error 500.19 - Internal Server Error Cannot read configuration file

I have been searching for this error all over the internet but no matter what I try to fix this problem nothing actually works. And the detailed message that I got after I copied a url from fiddler and put it in the browser and is as follows.
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \?\C:\inetpub\wwwroot\myservices\web.config
Actually what has happened in the past that I had this service called "myservices" working all fine when I used visual studio to create a virtual directory for it in IIS. But then what I did, I tried to do a web deploy of this service in IIS and removed ("myservices" from Default Web Site tree which I had created by creating a virtual directory from within VS 2013). And what I observed is, that after I web deployed "myservices" it didn't work the same way as it was working previously when (I created a virtual directory for "myservices" in IIS through VS2013 but had it removed to see whether the web deployed version of it would behave the same way). Therefore when I analyzed the cause of HTTP error 500.19 through Fiddler (for the web deployed service) it said (Config Error Cannot read configuration file and
Config File \?\C:\inetpub\wwwroot\myservices\web.config) but when I physically try to look into the folder C:\inetpub\wwwroot I could never find myservices folder as such (what to talk of web.config file in it). Then I manually created a folder called "myservices" in C:\intepub\wwwroot directory and put my web.config file there to see if the web deployed service would still work, but it didn't. Then I removed this folder called "myservices" and obviously the web.config file inside of it and also removed the web deployed service from Default Web Site Tree.
And now after all this mess even if I go to visual studio and try to create a virtual directory for my service "myservices" (I can see it in Default Web Site Tree in IIS ) but it would throw the same error as http 500.19 as the web deployed version of this service. In other words whatever I tried it messed up my services even when it's not a web deployed version which previously was not the case. I literally request everybody out there to please guide/suggest me with whatever experience they have as to what went wrong in all this trial and error endeavor of mine.
Thanks
This may be a long shot, but sometimes web.config files get corrupted (our code repository occasionally does this) and you cannot see it with the naked eye. take a simple web.config file that you know is not corrupt and start rebuilding the file from there if it works. We have also used a hex editor (like XVI32) where we can see the corruption, but its much easier to rebuild from a fresh file.
If your problem is not the web.config but the virtual folders, then do the same methodology. Start over with what works and go from there. It could be the web deploy tool that is causing the corruption.
When nothing worked, all I did, was uninstalled IIS rebooted my machine re-installed it again and the HTTP 500.19 is gone.It seems like my IIS was corrupted.

Style (.css) missing when added Azure Cloud Project

I'm in my way to convert an existing web site to Azure Cloud Service Project, but when I add this cloud project and debug my the project, the web page is missing all the styling, i.e. all the tabs in one page. I have seen that doesn't take the .css
Someone could tell me what's happening here?
Thanks!
Verify the *.css files, you need to make sure that the Build Action is set to Content:
You can try changing the properties of the cloud project -> Web -> use IIS Web Server..
worked for me
I had the same problem and I found it came from my use of IIS Express.
The problem was an error that can be seen in Windows Application Logs:
Src: IIS Express
"The directory specified for caching compressed content [...] is invalid. Static compression is being disabled."
fist I don't know if I have to write this as answer, if not sorry, I'll correct it.
About my question, I tough in publish it to Azure and when i did it, was working correctly. What I still don't know is why when I debug in VS with the cloud project is missing style and images.

cakePHP, what to do next?

I've followed some tutorials about cakePHP and now it's done, the "mvc" is ready.
What should I do next?
Meaning: I was working locally, can I simply upload the complete app online and it is secured as 'they' meant it to be?
I've downloaded the 1.3.6 package from https://github.com/cakephp/cakephp/archives/1.3, and deployed it as is in a folder named as my domain.
Edit:
I have win-xp with wamp.
I created the app by simply unzipping the file to a folder and then renamed it to 'domain_name'.
Then I made the db connection and set the configuration files.
At that point I created the models, views and controllers.
Now the application is working, locally.
My question is: can I simply upload everything to my server, to the html root folder and say that "I am done"?
As long as your app isn't already in production, putting it online can tell you more about how it's working. For instance, you'll learn if there are missing modules or dependencies that must be installed on the live server.
If it's an already live system, you may want to use an online staging server to understand what needs to be modified on the production server in order to have a smooth deployment.
There are three ways that you can deploy your cake app (Development, Production and Advanced), and all of them are secure:
http://book.cakephp.org/view/912/Installation
I would recommended the Production install if you aren't going to run any other apps on this server.

Resources