How to deploy Health Check in IIS as a Web App+WebAPI? - c#

I have built a HealthCheck app using nuget package (https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks)
I persist the Health probe status response in a Singleton object and expose it via my own custom Controller/Action method as a REST API. I did this to decouple the Health Check API Endpoint and abstract Health Check core services from external consumers.
Now coming to the issue. I want to deploy this Health Check App so that it will run as a background service as well as be queryable via my Custom WEB API REST Endpoint + Health Check API Endpoint.
Please share some ideas on how to do this.

healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/api/ping"]
start_period: 60s

Related

Service discovery ASP.Net Core with Ocelot

I may be wrong in my ideas but here the plan.
I have an app who has 2 services, with a client who consume these services.
Because I want them to be micro-services, I've planed to build an API Gateway to have only one access point and redirect requests.
I've found some docs for building this and I stumbled into Ocelot to do the job, it seems to fully answer my ideas.
But here the problem, if I want to run multiple instances of my services, I need a service discovery, that Ocelot can do with Consul, but it need in the service to register the service discovery provider in his configuration.
What I wanted to do is to discover services dynamically without configuring a service discovery provider in the services. Is it possible ?
Plus, if I want to run an another instance of the Gateway, the services will not register on this new instance.
Any hints or better solution ?

How to configure Azure CDN with front-end SPA and Azure WebApp with .Net Core WebApi to same custom domain?

I would like to have https://example.com as the custom domain for the Azure CDN I have setup, and https://example.com/api as the rest api endpoint to catch all of the calls from my SPA to the back-end .Net Core Web API providing the data.
How can I setup a custom domain on an App Service to serve the https://example.com/api and use the same custom domain for the Azure CDN to serve all of the front-end SPA web pages?
Right now, I have the custom domain configured for the App Service only, but I would like to move the front-end SPA to an Azure CDN to free up as many resources as possible for the Web API.
Thank you in advance, any direction would be greatly appreciated.
You can introduce another resource like Azure Front Door that can act as a proxy and hides both the CDN and your App Service behind a single domain.
Front Door allows you to configure routing rules so that requests for /api get routed to the App Service and requests for static assets get routed to the CDN.
You can then set your DNS CNAME to Front Door and all requests will be sent there rather than directly to the CDN or your App Service.
This gives you the advantage of not needing to worry about CORS, because from an outside perspective everything is coming from the same domain.
It also has additional benefits like allowing you to configure request throttling, SSL termination and global load balancing to name a few.
Unfortunately, it's impossible to add the same custom domain in two different public services since the CNAME record only can be used when there are no other records on that name when you need to add custom domains to your CDN endpoint and App service via a CNAME or A DNS record. See CNAME record wiki.
In this case, you could add a custom domain to your Azure CDN endpoint via a CNAME DNS record following this tutorial, but you need to create a subdomain like subdomain.example.com instead of the root domain example.com, then add the subdomain to the custom domains of Azure CDN endpoint.

How to get Service Fabric Reverse Proxy to work on Azure

I created a Azure Service Fabric Web API and planned to reach it through Service Fabric's built in Reverse Proxy.
All was working well locally but when I published to Azure, trying to access the route through Reverse Proxy would time out.
I thought it might be my app, so I just popped open a new solution with the default template and published to my local. Everything worked fine Reverse Proxy and all. So I published to Azure and again had the same issue.
I could access the Web API on azure through the normal route (through the endpoint of the service) for example:
xxxx.east.cloudapp.azure:8080/api/values
But going through the Reverse Proxy port of 19081 times out:
xxxx.east.cloudapp.azure:19081/[app]/[service]/api/values
I did make sure to tick off Enable Reverse Proxy when setting up the cluster resource on Azure, and set the port to 19081. Both of the above works fine on localhost, but only the normal route works on Azure.
Was wondering if there's some extra editing of the manifest or something I had to do to make it work on Azure correctly?
Did you see the documentation on how to configure it?
If you're going to expose services on the internet, be aware that the built-in one causes every service to become exposed, it's not hardened, it's vulnerable to DOS attacks.
Docs
I recommend having a look at Traefik as a reverse proxy and load balancer.
You can run it as a (containerized) ingress routing service inside the cluster, and direct HTTP calls to your services.
Here's the documentation.
Here's how to get started.
Here's an example.
Alternatively, you can use Api Gateway, which integrates with SF too.
Or even Nginx.

How do I extend class derived from StatelessService in Service Fabric ASP.NET 5 - based service?

Is there a way to subscribe to an actor event from ASP.NET 5 - based service? I saw similar feature in service-fabric-dotnet-data-streaming-websockets sample, but the sample uses OWIN-based web service and it has PublicGateway class derived from StatelessService where one can hook to the service Task RunAsync override. I haven't found any StatelessService-derived type in the ASP.NET 5 - based project code. Seems like it's auto-generated, if to look into the project ServiceManifest.XML?
The goal I'm trying to achieve is the same with the sample - I want to subscribe to events from actor service to publish them through SignalR hub.
The difference you're seeing is that the OWIN (Katana, to be precise) sample is a Service Fabric Reliable Service - a service written on the Service Fabric API - that uses Katana to open an HTTP listener. The ASP.NET 5 (now called ASP.NET Core 1) project you're seeing is what we call a "Guest Host" which is a separate EXE hosted by Service Fabric but doesn't implement any of the Service Fabric APIs. The reason it's done this way currently is because the current ASP.NET Core 1 hosting model makes it difficult to open a web server programmatically like we do with Katana.
However, this is changing. The upcoming RC2 of ASP.NET Core 1 will let you easily start a web server programmatically, similar to the way we do it with Katana, so you can write a service on the Service Fabric API and open an ASP.NET Core 1 server from the service. Here is an example using the RC2 build: https://github.com/weidazhao/Hosting
That said, you don't necessarily need to be inside a Reliable Service to hook into actor events. Any code running in the cluster can do it by pulling in the Reliable Actors NuGet package (Microsoft.ServiceFabric.Actors) and using the ActorProxy API. You can do this in a Guest Host service, you just won't have RunAsync as an entry point to do it in.

How to configure SSL on AppHarbor with ServiceStack.net web services

I am developing a set of web services using ServiceStack.net. I plan to host these services on Appharbor. I am fairly new to appharbor and cloud hosting in general.
I see that there is an interface within the dashboard to upload my SSL cert. What other configuration do I need to do to AppHarbor and/or my application to get this working properly?
Another note, My Servicestack services will be hosted within an MVC website. I will require all servicestack calls to be made over SSL and have implemented a request filter to check for this and throw a 403 if a non-secure call is attempted.
If you are happy with SNI SSL support, no further configuration should be necessary. Use this gist to determine whether a request is made with an SSL-encrypted connection.

Categories

Resources