Posts

Showing posts from June, 2018

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)

Setup a CI/CD pipeline with Gitlab for ASPNET Core on Ubuntu

Setup a CI/CD pipeline with Gitlab for ASPNET Core on Ubuntu Few weeks ago I explained how we could setup a CI/CD pipeline whereby the runner would be on Windows and the last stage was to package the application. Today we will see how we can setup a runner on Ubuntu CI server and use it to build and deploy an ASP MET Core application onto a Ubuntu 16.04 server. This post will be composed by three parts: Setup the runner on the CI server Setup the application on the server Setup the job in our project If you are unfamiliar with Gitlab pipeline and its terminology, you can read my previous post where I explain the main concepts behind GitLab pipeline with runner, jobs and stages . If you are unfamiliar with ssh and systemd, you can read my previous blog post on useful ssh commands and my previous blog post on how to manage Kestrel process with systemd . 1. Setup the runner on the CI server Setup the runner on your CI server by getting the package with apt-get. curl -L https

Bundle Bootstrap using Webpack

Bundle Bootstrap using Webpack Few weeks ago I talked about LibMan which was a tools preinstalled on Visual Studio 2017 preview allowing local download of cdnjs minified css/js. Today I will show how we can configure Webpack with npm to manage libraries like Bootstrap and minify both css and js while applying all its good algorithm like tree shacking. Get started with Webpack Bundle js Bundle css Multiple configurations 1. Get started with Webpack The goal of Webpack is to make it easy for developers to bundle code together and reduce its size in order to provide the smallest functional possible file to serve to users. In this post, I will show how we can bundle Bootstrap 4.0, both its js and its sass source code in order to provide two bundle, bundle.js and bundle.css . Before we look into Webpack, lets look at the steps which would be required to provide the bundles. Bootstrap npm package comes with js modules which are separated by functionality. For example for the moda

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