CosmosDB - Connect while App Running on 3rd Party Hosting - node.js

I have created a Node.js application, and a CosmosDB database.
When I connect to the CosmosDB database locally, all my Database calls work as expected, data is populated and updated in CosmosDB.
However, when I deploy the app to a 3rd Party Hosting site, my Database calls hang indefinitely. I have checked the configuration of the database connection, then environment variables on the server, etc., and am confident I have set everything up correctly.
Previously, I had deployed the app via App Service, and all worked fine as well, so I am very confident the issue has something to do with the fact that I am using 3rd party hosting. The app starts and, other than the database calls, works as expected on the 3rd party hosting site.
I have contacted the 3rd Party Hosting provider, and they say all looks normal on their end.
I am using the MongoDB CosmosDB API.
Is there something that I have to configure in Azure Portal, or something that might be blocking the connection when it is deployed using 3rd party hosting? Help is much appreciated. Thank you

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 make an API accessible all the time and not just when the project is executed?

I am making my first mobile app using Xamarin.Forms and FreshMVVM as the architecture and I want this app to get info off my SQL database (which is located in azure) by calling an API Rest. I already know how to develop an Api, and all the SQL and Azure related stuff, as well as how to get info from my API.
But what I don't know is how to access this API when the project in which is created is not executed, in other words, I don't know how to make my API Rest accessible all the time, so the App can access to it whenever is needed.
How do you do this?
Thank you all for your time, hope you have a good day.
You need to publish the API to a web host. Azure App Services. AWS. Digital Ocean VM running a web server. Possibly GoDaddy, though I have never used them. Your own server.

Azure App and Services and IdentityServer4

I have a situation where I have a React Web App and two REST services using Identity4 Server.
Problem is that these work well locally in my Workstation but if I deploy these three parts into Azure they will not work.
I have Azure SQL Database containing all Databases and tables it needs. Locally I use my local Database. So, Database is not the problem. It's deployed in same way with Azures manner.
My question is that how should I configure a React Web App using Identity4 Server with REST services?
I thing that Azure needs some kind of proper configuration but dont't know what.
I also have read Identity4 Server's documention pages but haven't found anything there that would help mr installing it into Azure.
Can anyone help me with this issue? thanks
Br
Mike
One error is HTTP 401 Unauthorized error

Running Angular5 app locally against Azure AD protected backend

We have an Angular5 application with a DotNet OData backend API. The application is hosted in a Web Application with a virtual directory for the Angular5 app and another virtual directory for the DotNet backend. The web application is secured by Azure AD, with an Azure AD Application defined for the web site.
This all works perfectly. We have no authentication code in the front end (except for 'withCredentials: true' set in the service calls) but apparently having the whole application protected by Azure AD makes the front end able to call the backend without issue (Azure makes you authenticate when you access the Angular5 front end).
The problem comes when we try to develop the front end. When developing Angular5 one needs to run the Angular5 code locally, so I've set up a web app which hosts only the backend code and point the local configuration for the Angular5 app there. This fails with the first backend call with a 401. One of our developers discovered that if you simply plug in the URL to the backend with the same browser (i.e. copy the failing call from the browser network developer tab into a new browser tab in the same browser) you will go through the authentication process and then when you run the local Angular5 app again it works. We thought we had found a workaround until we noticed that for some reason this only seems to fix the "read only" calls. GET works, OPTIONS works but POST fails with a 401. I put some debugging code in the backend but it seems this code does not even get called (i.e. Azure, not our backend, is blocking the call).
So I've tried to figure out how to get the local Angular5 instance to behave as the one hosted by the Web app but I can't figure out what I need to be doing. I have also been unable to find anyone else doing this so I can't find a solution.
I have tried various solutions of actively getting a token (e.g. setting up /.auth/me, using adal5 to "login", etc.) for the front end but it seems every possible solution is defeated by CORS in the end. Our backend has an Allow-Origin for localhost:4200 but this doesn't apply to login.windows.com for the authentication step. I tried putting localhost:4200 in the CORS setting on the Azure Web App but then it complains about an Allow-Authentication header being missing and I have no way to force Azure to provide that. I read online that this is happening because Azure didn't expect people to be using "cookie authentication" so after some research I found that "cookie authentication" was being used because of the "withCredentials: true" calls, so I changed all of those to false. Then the Allow-Authentication failure goes away but I just run into more CORS failures during the authorisation (login.windows.com).
So I'm really stuck here. I can't believe I'm the only person on earth who's trying to run a local instance of Angular5 against an Azure AD secured Azure Web app backend but I can't find any examples anywhere of people successfully doing this. I also would like to avoid having to do some elaborate local authentication because the code works perfectly as-is when hosted on the same Azure Web app as the backend. Does anyone have a setup like I describe that is working?

Correct way to deploy a Restful WCF service

I've created a simple RESTFul WCF service that returns JSON formatted data.
This works swimmingly when I'm hosting it in my dev environment.
I use the following uri format:
http://localhost:8732/Service1/GetMetric?RunNumber=49653&MetricName=Res_Side_Coeff&SampleNumber=2
My problems begin when I want to host it on a server. If I publish it, an svc file is created. This is no use as I have to create a wsdl, which is fine for a VS C# project to bind to, but not for me as the consumer of this is going to be an external, non c# tool. Therefore I just want to keep the access to it exactly the same as when in development.
How do you deploy to an IIS server (8.5) to achieve this and what configuration settings do I need?
I decided to try to create a WCF Service application rather than a library, this works fine, though I still dont know why the library doesn't work.

Resources