How to deploy and host .NET Core self-hosted console apps in Azure? - azure

App 1: I have a React app (based on create-react-app) which I've added as a Web App in Azure - that was pretty straight-forward to setup. This is using the JS SignalR client to communicate with the server, mentioned next.
App 2: This app is the ASP.NET Core SignalR Server application created with dotnet new console. This app exposes a SignalR endpoint and is "self hosted".
App 3: A 2nd ASP.NET Core console app is setup as a SignalR client. This is responsible to fetching some data, and sends those data to the SignalR server. This takes the SignalR endpoint (url) as a commandline argument.
Running all this locally is pretty straightforward:
App 1: npm start / serve -s build
App 2: dotnet run -commandline args (runs on localhost taking a hubpath and port from the args supplied. The port is so that multiple instances SignalR servers can run on localhost - not sure if this is the way to do it in Azure or if they're differentiated with separate urls and hosted seperately there)
App 3: dotnet run "http://localhost:5000/somenotificationhubname"
I've added a bat file in each of the console apps, so I can open multiple instances of those, with different args.
So locally it runs as easily as clicking 3 bat files.
But I'm kinda lost on how to host all this in Azure. The web app seemed pretty straightforward. I just created a web app in Azure, connected to it through an FTP client and copied over the contents of the build folder from the React app.
But what to do with the ASP.NET Core console applications so that the SignalR console app will be hosted in Azure and has its endpoint exposed for the other 2 apps to consume?
I tried adding both both App 2 and 3 as webjobs under App 1, but that didn't seem to work.
I've also heard that SignalR should not be running on IIS, so would it make sense to make it self-contained (exe) and run it inside a docker container? Any help is much appreciated.

I will suggest to change your app to use AppSettings file for configuration values instead of the commandline args.
You can easily change the value of appsettings without redeploying or changing anything.
You can have multiple appsettings file based on environments.
Allows you to easily duplicate the app with same code but different appsettings for your multiple signalr server.
This will make it easier to deploy using the standard publishing wizard in Visual Studio or via command line.

You could try the publish Profile in Azure App Service with the help of Visual Studio,
Reference 1
Reference 2
Once you successfully publish your webApp. You can double check the deployment using kudu service (or) App service editor
Advanced Tool-KUDU
AppService editor

Related

Azure: change an existing Windows Web App to a Linux Web App (docker)

I have an existing Windows Web App in Azure which I want to migrate to a Linux (docker) Web App. It is easy to setup a new Linux Web App with a new URI and that all works. However, I need to preserve the existing URI (myservice.azurewebsites.net) that I have on the Windows Web App and use it in the Linux Web App.
Any downtime is not acceptable, so I cannot just "test" if I can remove the current Windows Web App and "re-use" the same URI.
Created ASP.Net Core Web App and deployed to Azure Windows App Service.
Tried to deploy the same Web App to Linux App Service(Docker), got the below warning.
Tried to continue the steps to provide the configuration access to docker container, got the below error.
For the apps which we want to deploy in Azure Linux Docker, we need to Enable Docker and provide Docker OS , which is not required for Azure Windows App Service.
remove the current Windows Web App and "re-use" the same URI.
It is suggested to create a new App Service Plan and deploy to Linux App (Docker).

How to Deploy Blazor Webassembly Web Application to Azure?

I have created a Blazor Webassembly web application with the PWA feature. It is a CRUD application.
This is my folder structure:
Now I want to deploy it to azure. How can I do that?
The server app is just an ordinary ASP.NET Core application (this is the app that needs to be published). You have several options, like publishing the app to an Azure App Service or an Azure virtual machine. The former would require you to prepare a Docker image (usually a good start would be to enable Docker support for the server project and tweak the created Dockefile to your needs).
Just read the docs at https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-webapp-using-vs?view=aspnetcore-5.0 to get the full picture.

deploying frontend and backend to the same web service on azure

i have a web app that has a seperate nodejs backend and angular frontend.
is it possible to make them both run on the same azure web service? or do i need a stand alone service for each?
my nodejs server is just a light API that feeds my angular app with some statistical data to render it. if it is possible what would be the way to do it?
since i am using typescript i know i need to push my nodejs using zipdeployment and i know i need to use visual studio to push my angular project to azure. but when i want to run both on the same service, how do i do it?
is it possible to make them both run on the same azure web service? or do i need a stand alone service for each?
If you choose the Web App on Windows OS, IIS allows you to configure multiple virtual applications within a single website. For this approach, you could follow Deploying multiple virtual directories to a single Azure Website. Note: The multiple virtual applications would share the same application pool.
As kim mentioned, you pay for the App Service Plan, not for the Web App. You could also host nodejs backend and angular frontend in different web apps under the same app service plan.
For the deployment, you could leverage VS publish wizard or manually upload your files via KUDU or FTP. Moreover, you could also follow Deploy the app section about various approaches for deployment.
You can run multiple web sites in different web apps in Azure so that they are sharing the same Azure App Service.
You can think of the App Service as a virtual machine offering resources for your applications. How many web apps you can run simultaneously depends on the size of your plan, see this page for details.
This way you can deploy them separately, manually or automatically using e.g. VSTS.

How to setup iis in Azure web app service with Net Core 2 app?

I develop simple Web Api on Net Core 2 and add Angular app to it (inside wwwroot folder) and publish it from my VS 2017 IDE to Azure Web App Service. All work fine, but when I reload page of my app in browser, server can't find route. So It often happens when iis not setup for SPA, It's described in https://angular.io/guide/deployment, I must configure the server to return the application's host page (index.html) when asked for a file that it does not have. How I can setup server node of iis in Azure Web App Service (web.config in Net Core 2 was deleted).
I am afraid you cannot achieve this.
Cause: Azure App Services runs IIS so it behaves mostly the same as local IIS, routing requests using a native module called AspNetCoreModule. So, it needs your published web.config file. Even though you deleted the web.config file, Azure would also generate a new web.config file to be used.(Though I don't understand why you delete the web.config file)
Solution:
Even you can upload the web.config file to Azure again, I'm afraid of that it will be ignored and doesn't work. So, I suggest you redeploy your website which contains web.config file to Azure and configure it well.
Additional: Azure Web App service is a kind of PaaS. So, if you want to install IIS manually, you can choose to host your website on a Windows Azure VM.

Azure worker role does not seem to start

We are building webapplication with an AngularJS frontend and a Web.Api backend. Both need to be hosted in Azure. To support this we created two projects:
A worker role with an endpoint on 8080 for the web.api (converted from a selfhosting web.api)
A web role on port 80
Both roles are combined in one azure service project. When running the project local in the azure emulator we have two endpoints that are working as desired. Localhost gives back the website, localhost:8080/api gives back the api. Together a nice website is running.
When deploying it to the staging environment on azure it publishes correctly. After done publishing, when we go to the site the sites loads up. The api does not work though.
When we go to the instances tab in the azure portal, we get 2 instances running in the project. 1 for XX.Azure.Worker_IN_0 and one for XX.WebRole_IN_0.
We looked in the eventlog of the worker role, but we cannot find any problems. Is there anyplace where we should look for errors? We tried searching for it but we couldn't find a log on the server. Or are we doing things with azure that we are not supposed to do.

Resources