Posts

Showing posts from 2018

Bundle Bootstrap using Webpack

Bundle Bootstrap using WebpackFew 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 WebpackBundle jsBundle cssMultiple configurations1. Get started with WebpackThe 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 modal, it is located und…

Custom Minio Grain Storage for Microsoft Orleans

Image
Custom Minio Grain Storage for Microsoft OrleansGrains 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 MinioImplement grain storage interfaceRegister the grain storage1. Implement a simple blob storage abstraction and implementation with Miniointernal 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 blobName, string blob…

ASP NET Core with Nginx

ASP NET Core with NginxFew 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 nginxConfigure nginxHost ASP NET Core1. Install nginxStart 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 journalctl -xeu nginx If you ar…

Manage Kestrel process with systemd

Manage Kestrel process with systemdKestrel is a lightweight standalone process. In order to host it on Linux, the recommended approach is to install it as a service. Systemd is a group of tools providing functionalities to manage processes on Ubuntu.
Today we will see how we can manage an ASP NET Core application together with its Kestrel process using systemd tools. This post will be composed of three parts:IntroductionManaging process with systemctlDebugging using journalctl1. IntroductionASP NET Core application runs on top of Kestrel which is a lightweight standalone webserver.
To be able to start to interact with our Ubuntu server we need to first establish an ssh connection. If you aren’t familiar with ssh, you can refer to my previous blog post where I provide explanations on how to setup ssh.Once we are on the server, we can get our libraries on the server and run:/usr/share/dotnet/dotnet myapp.dll This will run the app from the current session. When we exit the session, the a…

Useful bash and friends commands

Useful bash and friends commandsSince I have installed Ubuntu as a subsystem, I see myself using more and more bash. The reason being that all the VMs I spin up are Ubuntu VMs. My interactions with my servers are very basic but even for those, there are many beautiful commands which ease my interactions. Today I would like to go through the commands and tips which I use on a daily basis:sshscpaliaseslessgrep1. ssh1.1 Remote actionsThe ssh command allows us to remotly access a terminal or to execute commands remotly.For example when we create a new EC2 instance on AWS we can download the private key.
This key can be used to ssh into the vm.ssh -i key.pem user:hostname -i is used to indicate the identity file to use. You might need to change the permissions on the file before it can be used with chmod 700 key.pem.It is also possible, to make life easier, to setup ssh to autodetect the private key file to use based on the host we are trying to access.We can achieve that by placing the ke…

ASP NET Core Client-side libraries management with VS 2017 Library Manager

Image
ASP NET Core Client-side libraries management with VS 2017 Library ManagerFew weeks ago I discussed how we could create a healthchek library which would return json status of our application. Using the json, I wanted to make a quick page to display healthchecks in a nice visual. I wanted to quickly add Bootstrap and momentJS. For frontend libraries, I was used to use Bower as it nicely put every frontend package in /bower_components which can be served as static data. But since Bower was announcing that it was no longer supported and requested to use Yarn or NPM, I started to look around for an easier solution than those as I don’t really care about source code of the frontend libraries, all I want is the latest compiled versions. After few minutes of research, I found out that the team in Microsoft felt the same way as I did and already worked on a tool called Library manager (libman) and is available in VS Preview for the moment. Libman gives the benefit to allow developers to downl…

Async pipe versus Subscribe in Angular

Async pipe versus Subscribe in AngularOver the past year, working in companies using Angular, many times have I been in situations where I was asked to explain the differences between async pipe and .subscribe in Angular.More precisely explain my standpoint which is to always use async pipe when possible and only use .subscribe when side effect is an absolute necessity.The challenge in explaining this comes to how to convince without giving an hour boring lesson of why side effects in logic are hard to maintain and how prematured .subscribe forces developers to make unecessary side effects.So today I would like to talk about that and provide explanations which I hope will help to understand which to use. This post will be composed of three parts:Observable and RxjsSubscribe functionAsync pipeBest practices1. Observable ans RxJSFirst to understand the context, we need to understand what is an observable.1.1 ObservableObservable is an abstraction of asynchronous stream of data.
For exam…

Healthchecks in ASP NET Core

Healthchecks in ASP NET CoreHealthchecks 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 usageBuild the frameworkSqlite Healthcheck extension1. Define the usageASP 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(IServiceCollection services) { …