Showing posts from 2018

Estimating cloud infrastructure cost

Estimating cloud infrastructure costFew weeks ago I was tasked to estimate a cloud architecture with limited requirements.
Today we will see the rules which can be followed in order to come up with a price tag. This post is composed by three parts:Defining the requirementsSolution needsPrice1. Defining RequirementsBefore starting any estimation, it is important to get at least one requirement. In this example we will invent a scenario, really close to what I had irl, whereby we would be setting up a Christmas tree website with the following requirements.The trees are put to sale accross the whole year in advanceWe have about 50k purchases where 80% happens from November to DecemberThe most important aspect to remember is that estimates are estimates. It will never be exact, even if it happens to be exact, we probably got lucky. The goal of the estimates are to evaluate the magnitude of the price of an infrastructure whether the infrastructure would cost $100, $1000, $10K or $1M monthl…

Remote PowerShell to Windows VM with WinRM

Remote PowerShell to Windows VM with WinRMThe Remote Desktop Protocol is great to access remotely a Windows Server machine. It is great for actions requiring visual but for actions which can be taken from a PowerShell prompt within the server, it would be best to directly access to a remote PowerShell session from our local computer. Today we will see how we use the Windows Remote Management included in Windows Server to gain access to a remote PowerShell session and therefore manage our server from our local computer through PowerShell. This post is composed by four parts:Open ports on Network Security Group and open ports on VM firewallSetup the certificate for HTTPS communication with SSLConfigure WinRMConnect on remote session1. Open ports on Network Security Group and open ports on VM firewallFor Azure or AWS, on the security group, the port 5986 needs to be open. It is the port used by WinRM for a PowerShell remote connection over HTTPS.Next RDP to your VM and open the same port…

Install dotnet on Ubuntu with the Linux subsystem on Windows 10

Install dotnet on Ubuntu with the Linux subsystem on Windows 10Dotnet and ASP NET Core are rapidly moving toward cross platform development. As of today, we are already able to write dotnet application running on Windows, Linux or docker. But when our development environment differs from our production environment, for example using Windows for development while deploying on Ubuntu, it can be hard to catch problems early. What we can do is spin off a virtual machine which we can use to test our application for development pruposes. Recently a new approach came to life thanks to Windows subsystems which allows us to run a Linux binaries executables natively on Windows 10. Today we will explore how we can run a Hello World ASP NET Core application locally on Ubuntu on Windows 10. This post will be composed by three parts:Install Linux subsystem on Windows 10Install dotnet on UbuntuRun an ASP NET Core behind nginx1. Install Linux subsystem on Windows 10Start by enabling WSL via PowerShel…

Logging in ASP NET Core with Serilog

Logging in ASP NET Core with SerilogAt each stages of an application development cycle, good logs are necessary to debug and fix bugs efficiently.
Serilog is a logging framework allowing developers to log structured logs into different ouput platforms.
Today we will see how we can set it up in three partsSerilog for ASP.NET CoreConsole sinkRolling File sinkEnvironment enricherAll the code discussed here can be found on my GitHub Serilog for ASP.NET Core1.1 Structured logsLogs are string messages describing an event in the system. They are built by assembling pieces of information, elapsed time or process name, into a string message. Once constructed into a message, they are written into an ouput stream, console or file for example.
The message contains the timestamp the log message. The log message being a string, all we can do to query it is a full text search query.
If our log contained the elapsed time, it would not be easy to run a under/…

OAuth 2.0, OpenID Connect and Identity Server

OAuth 2.0, OpenID Connect and Identity ServerWhen it comes to authentication and authorization, the most used standard is OAuth 2.0 with OpenID Connect (OIDC).
Few weeks ago I discussed Resource owner password and Implicit flows focusing mainly on implementations with Identity Server. There is a lot of confusion revolving around OAuth 2.0 and OIDC, what they are, how they differ and even what Identity Server is and what is it used for. Today I will give more insights on what is OAuth 2.0 and OIDC are and how Identity Server relates to them.1. What is OAuth 2.0 2. What is OpenID Connect 3. What is Identity Server 4 1. What is OAuth 2.0OAuth 2.0 is an authorization protocol enabling applications to have a limited access to protected resources. The authorization is handled in the Identity provider (Idp) who is in charge of delivering an access token to the client apppication after having authenticated the resource owner (usually the user).Why do we need it?Let’s take an example.I have an…

SSL with Let’s Encrypt

SSL with Let’s EncryptFew months ago I explained briefly how SSL could be setup with CloudFlare. Today I would like to share another way to get a SSL certificate for free via a browser based implementation of Let’s Encrypt.
This post will be composed by two parts:1. How SSL works 2. How to get the certificate 1 . How SSL worksSSL provides a secure layer on top of HTTP. It allows to encrypt communication between client and server in order to prevent man in the middle attacks and eavesdropping.An SSL is composed by two pieces, a certificate and a private key.
The private key must be securely kept by the server while the certificate is distributed to all client.The goal of the SSL is to ensure two things:Encryption of data between server and clientAuthenticity of the certificate provided1.1 Encryption of data between server and clientThe encryption is established by an asymetric key pair.
The private key is held by the server while the public key is distributed to clients within the cert…

Params inheritance strategy with Angular Router

Params inheritance strategy with Angular RouterFew weeks ago I discussed about Angular router, how we could make sure our data are loaded before accessing a component. If you aren’t familiar with Angular router, I suggest you have a look at my previous blog post where I introduced the router.
The example was loading data from the store (ngrx store) to check if data were loaded.
But it would have been difficult if we needed to load data from the route params. Today we will see the problem faced when taking params from the route and how it can be resolve with a newly introduced feature in Angular router since 5.2.x.1. Getting data from the route params 2. paramsInheritanceStrategy 1. Getting data from the route paramsTo get data from the route params we take can use the ActivatedRouteSnapshot or the .snapshot property of the ActivatedRoute and use the .params property. Suppose that we have a route /test/:myKey, and we navigate to /test/hello, we could do the following:const key = route.…

Start processes from C# in DotNet Core

Start processes from C# in DotNet CoreBeing able to run batch during the lifecycle of an application is always useful. It gives a way to programmatically interact with any programs which implements a CLI. Today we will see how we can start processes from C# on .NET Core applications and how it can be useful in a real scenario1. Unzip from CLI 2. Use CLI from C# 1. Unzip from CLIIn this tutorial we will use a process to execute a 7zip command to extract files into a particular input.If we have 7zip installed and added to PATH, using a terminal, we should able to execute the following from the folder containing the archive:7z x .\\ -o.\\archive x stands for extract and -o stands for output directory. The result of this command should be the list of files in extract unzipped into the archive folder.There are times where it comes handy to zip and unzip as part of an application lifecycle, for example to allow a user to download multiple files from our server, we could zip them …

DotNet Framework, Standard, Core and ASP Net Core

DotNet Framework Standard Core and ASP Net CoreLot 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 FrameworkEverything 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 in order to…

The Steps Toward Leadership

The Steps Toward LeadershipAs a Software Engineer, I have gone through many managements, different countries, different companies, different projects which all left me with a bitter taste.
After years of reflection, I realized that half of the feeling came from my inexperience while the other half was meant to be fulfilled by the management under which I was working. This management was meant to provide me, a Software Engineer, the direction, vision and ideology to carry on my work. Management composed of line managers, higher management, directors and company, I expected them to lead me to success.
It is incredibly hard to find the right way to get a Software Engineering team to work well. Most of the challenges aren’t well understood by those coming from different backgrounds. Not that it is harder or easier, it is just different. Tasks aren’t easily measured, it is hard to make KPI, goals aren’t easily defined and set, and many more issues. We have seen that giving management respo…

Setup environments for your AspNetCore backend and Angular frontend

Setup environments for your AspNetCore backend and Angular frontendLast week we saw how we could use angular cli and dotnet cli to pack and publish our application with simple commands. The application had no settings therefore there wasn’t a need to differentiate multiple deployments. But if we do need different settings, how should we handle it?
Today I will amswer this question by explaining how we can setup targets and environments for our application. This post will be composed by three parts:1. What is the difference between a target and an environment 2. Setup target and nvironment settings for AspNetCore app 3. Setup target and environment settings for Angular CLI 1. What is the difference between a target and an environmentA target refers to a target build. A target build is a set of configurations used to build the application. For development, the optimization is usually disabled as build time is more important than the optimization of code for example which would slow down…