Posts

Showing posts with the label .NET Standard

Multi environment logging with Serilog for AspNet Core

Multi environment logging with Serilog for AspNet Core Few months ago we saw how to get started with Serilog. We discovered what was Serilog and the different concepts of settings, enrichers and sinks. Today we will see how we can take Serilog further and configure a logging mechanism for an application running in multi environment. Setup Serilog Multi environment AWS CloudWatch 1. Setup Serilog If you have never seen Serilog before you can start with my previous post on How to get started with Serilog . In order to configure our first logging mechanism, we start by creating an AspNet Core application and install Serilog , Serilog.AspNetCore and the sinks we will be using Serilog.Sinks.Console , Serilog.Sinks.File . RollingFile sink also exists but it has been superseded with File sink. Next we can configure the logger to write to Console and write to a file: public static IWebHost BuildWebHost(string[] args) { return WebHost.CreateDefaultBuilder(args) ...

Custom Minio Grain Storage for Microsoft Orleans

Image
Custom Minio Grain Storage for Microsoft Orleans Grains states in Orleans are stored in a grain storage. Orleans ships with multiple highly available storage implementation like Azure blob storage or AWS Dynamodb. Today we will see how we can implement our own grain storage which will store grains on Minio , an open source free private cloud storage. Implement a simple blob storage abstraction and implementation with Minio Implement grain storage interface Register the grain storage 1. Implement a simple blob storage abstraction and implementation with Minio internal interface IMinioStorage { Task<bool> ContainerExits(string blobContainer); Task CreateContainerAsync(string blobContainer); Task<Stream> ReadBlob(string blobContainer, string blobName, string blobPrefix = null); Task UploadBlob(string blobContainer, string blobName, Stream blob, string blobPrefix = null, string contentType = null); Task DeleteBlob(string blobContainer, string blobNam...

ASP NET Core with Nginx

ASP NET Core with Nginx Few weeks ago I showed how to host ASP NET Core on Windows Server behind IIS. Compared to Windows Server, Ubuntu with nginx offers a quicker way to get started and a better control over the kestrel process. Today we will see how to host an ASP NET Core application on Ubuntu. This post will be composed of three parts: Install nginx Configure nginx Host ASP NET Core 1. Install nginx Start by installing nginx. sudo apt-get update sudo apt-get install nginx After installing nginx, the daemon should have been installed and started. We should be able to navigate to http://localhost and see the nginx default page. This page is the default root folder of nginx which can be found under /var/www/html/ . We should also be able to interact with it just like any other daemon managed by systemd : sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl status nginx And similarly it can be debugged via journald : sudo jo...

Healthchecks in ASP NET Core

Healthchecks in ASP NET Core Healthchecks are used to assess the health of an application. There are multiple level of checks which can be implemented, the first level being whether the application is itself running. The second level being whether the application dependencies, services, databases, files, are accessible by the application. Last level being whether the process itself is healthy, consume a reasonable amount of CPU/RAM. Today we will see how we can implement a simple healthcheck middleware for ASP NET Core in three parts: Define the usage Build the framework Sqlite Healthcheck extension 1. Define the usage ASP NET Core is cooking a healthcheck framework but the nuget package hasn’t been created yet therefore only the codebase is available. The framework in this post is a simpler version inspired by the official healthcheck framework. We will be creating a framework allowing us to register comprehensive healthchecks. public void ConfigureServices(IServiceCollecti...

Microsoft Project Orleans ClientBuilder and SiloBuilder

Microsoft Project Orleans ClientBuilder and SiloBuilder Prior 2.0.0 stable, we used to configure client and silo using ClientConfiguration and ClusterConfiguration . I was hard to understand how to configure those as many options were available. Moving forward to 2.0.0 stable, ClientConfiguration and ClusterConfiguration no longer exist! It has now been replaced by a ClientBuilder and a SiloBuilder (notice there is no cluster builder). The shift toward builders makes life easier to us to configure client and silo. Today I want to take the time to explain how the migration between beta 3 and stable can be done in three parts: Configure ClientBuilder Configure SiloBuilder 1. Configure the ClientBuilder A client needs to connect to a cluster. The only configuration needed for the client is therefore: the id of the cluster the id of the service where to find the cluster During beta this used to be configured in ClientConfiguration , it is now done using the ClientBuilder :...

DotNet Framework, Standard, Core and ASP Net Core

Image
DotNet Framework Standard Core and ASP Net Core Lot of things have changed from the past few years in the DotNet ecosystem. In many occasions, I have seen people get confused with the differences between DotNet Core, DotNet Standard and DotNet Framework and how do they all relate to ASP Net Core. I don’t blame them, so many new keywords that it is quite confusing to first look at. Today, I would like to explain the differences in term of project templates. What is the difference between DotNet Standard library or DotNet Core library, what is the difference between DotNet Core application or DotNet Framework application, etc… This post will contain 5 points: 1. DotNet Framework 2. DotNet Standard 3. DotNet Core 4. How to choose 5. ASP.Net Core 1. DotNet Framework Everything started from DotNet framework. We would build libraries, console app and web application using ASP.Net MVC on top of DotNet Framework. DotNet framework provides a set of API available for application to use ...