Setting node.js site to auto-start when hosted in Azure Web app - node.js

I have a Node.js script that I want to run in Azure on a Web app.
This script is not an express web site, rather it's a worker script which polls a database for work to perform, and when done it just polls and waits, e.g. there is not user interface for it.
I notice that after deploying it, even though it's setup with iisnode, it won't actually start until I fire up a browser and navigate to the Azure Web app host, even though it doesn't have a UI.
Only when I navigate to it does iisnode start logging and fire up my application. Then it happily polls the database and performs the required work.
Does anyone know how you can make a site just automatically start when deployed?
There seem to be autostart web.config settings available with IIS, but I don't know how to get iisnode or the Azure Web app to support it.
I could set up a Web job on the machine that just performs a GET from the site, but that seems a bit of overkill and messy.

You can leverage Function App to satisfy your requirement. Also, your original solution which build an Azure Web App without UI should be work.
However, please pay attention that Azure App Services will be unloaded after they have been idle. You can enable the Always on application setting to keep the app loaded all the time. Please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/#application-settings for more details.
Any further concern, please feel free to let me know.

Related

how to run a node server in an azure virtual machine permanently?

I build a web based mobile app (using react), which I'm hosting as an Azure Web app. This website is connected to a node server, which I'm hosting using a azure virtual machine (I don't know if this is the best approach, maybe I should host this as a webapp instead of VM ?).
I'm still new to this strategie of developing a web based mobile app and connecting it to a hosted backend in the cloud so I apologize if this is a trivial question.
I'm using websockets to connect my frontend to the node server and then I consume messages. I don't have a database it is a simple application.
The steps I'm doing to run the app are:
I connect to the Azure VM from my laptop with ssh
run my server using node server.js
When the server is runing, I can refresh my website and everything works fine
Now, the problem is that I want the node server to run all the time. However, I noticed that the server stops running when I deconnect (ssh) my laptop from the virtual machine. So I find myself doing these steps (connecting to the VM with ssh and running the server manually) each time I want to use the app.
Is there a way to do this so that the node server runs all the time without stoping? Also since I'm new to this, is this the right way to deploy frontend and backend? I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
(Since part of your question is around "Is there a better way?", I would answer that instead of fixing the issue in your current VM hosting :)).
To take full advantage of cloud for your applications, PaaS is always preferred over IaaS. In this case, unless you have any specific reason, you should deploy your backend Node app in another App Service (aka Web App). Or you can consider Azure Function also if your node app has a small set of APIs, but it will require code update. Both support multiple platforms including node.js. Since you mentioned you are leveraging Web App for your react mobile app, so I hope you are already bit familiar with it. Also since Azure Function would require code change, so Web App is preferred this case.
Note: I omitted other solutions like AKS, Service Fabric etc. for now, since currently we are talking about the problem of deploying only a single app, for which those will be overkill at this moment.
Also, to your point
I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
Yes technically you can, depending on your scenario by "bundling" into a single app if both are in same platform (like Node in this case). Though whether one should do that would be an opinionated answer. But even if you keep those separate, you can still leverage single App Service Plan for cost saving. So keeping separate like you have now is what I would suggest to maintain "separation of concern".

How to configure warm-up of web-service application within Microsoft Azure

On IIS I can configure my web-service with Application Initialization, AlwaysRunning and Preload enabled to make sure the first request is fast enough. Now I am trying to create a similar web-service within Microsoft Azure. However, the first request is exteremely slow. I tried to speed it up using "Always on", but this doesn't work. What configuration is needed to make sure the warm-up works correctly in Azure?
I would like to make Azure react the same way as IIS when restarting the application or refreshing the web.config. Besides the "Always on" functionality, I can't find the settings that are needed to do this. I have searched on other pages, but most solutions are about the warm-up of a website page. Is there a (simple) configuration to use for the warm-up of a web-service within an Azure app service?
Have you enabled Preload?
When you create the Web Service Application in azure...
Under Settings, Configuration, Path Mappings..

Is it possible to use a local IIS service in a UWP app

Is it possible use have a web-browser control inside a UWP app that connects to a local web server?
I can have the app connect to a live service, but some users need to be able to get access to web pages while working off-line.
Ideally, I'd like to replicate the feature on a local service, but I can't find anything to support this sort of feature. My guess is, it breaks the sandbox rule for UWP apps, but I thought there may be somebody that has been able to make this happen.

Azure Web App equivalent of IIS IdleTimeout

I've got an ASP.NET MVC site hosted as an Azure Web App and I've noticed that once the site has been idle for a while, when hitting it the application reverts to a deployed state.
Now traditionally, I would solve this problem by setting the Idle Timeout of the application pool in IIS to 0. However, given that I don't have ready access to do this with an Azure Web App I'm struggling to find the equivalent.
I did try the "Always On" setting which appears to be what I'm looking for, however it seemed to make absolutely no difference unfortunately.
Always On. By default, web apps are unloaded if they are idle for some
period of time. This lets the system conserve resources. In Basic or
Standard mode, you can enable Always On to keep the app loaded all the
time. If your app runs continuous web jobs, you should enable Always
On, or the web jobs may not run reliably.
From https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-configure
Make sure you're running in the right price tier (Basic / Standard).

Automatic Browse Service.svc file in iis

I have created a WCF service which i have hosted in IIS. When I start the service in IIS, the Service do not started until I browse my Service.svc file.
Application pool gets recycled after a specific interval, then when the Service is restarted I again need to go and browse the Service.svc file.
I have set this Service as Default bt it does not work and results the same.
Is there any way to automatic browse my Service.svc file when the Service is started or restarted.
This is a general annoyance with IIS. It launches worker processes to perform website processing which don't (always) start until the website has been requested. The workaround I've used in the past is to hit a page outside of my web application to launch the IIS worker process so it is available when I need it. Be careful though there are some nuances to the app pools that can make this more complicated than it needs to be.

Resources