Azure

End to End SSL solution using Web Apps and Azure Application Gateway multisite hosting

High performance and security (amongst other things) are the 2 non-functional requirements that usually first come to mind when we design an infrastructure architecture for the applications we develop. The usual 2 concepts that pop up with these 2 requirements are load balancing and firewalls. How can you easily achieve and check these 2 concepts when you are developing your architecture in Azure? One component that you can use for this is the Azure Application Gateway. Azure Application Gateway is a web traffic load balancer (OSI layer 7 load balancer) that enables you to manage traffic to your web applications. Some of its features include (but not limited to): URL-based routing: make routing decisions based on additional attributes of an…

Read more
Azure, Docker

Connecting to Azure Redis Cache with Docker

If you are a Windows user and you want to access your Redis cache, you probably have realized that getting the redis-cli for Windows is not as easy as 1,2,3. You probably also wandered around the internet trying to find a free GUI that does the job of access Redis in a secure way (that is that is supports SSL/TLS out of the box). You then realized again that they probably have limitations themselves and it’s also not easy as 1,2,3. Your last solution, use the redis-cli that comes with the redis server on a linux flavored distro. Lucky for you, in Windows 10, you can install the Linux subsystem and then install redis which includes the redis-cli. Great, but…

Read more
Azure, C#

Loading a X509 certificate from Azure KeyVault into a .NET Core application

In a context where we are now using APIs a lot more than we used to, it becomes important to secure them. One way we can secure them is using the OAUTH/OpenId protocol, which relies on Json Web Tokens (JWTs).  A JWT needs to be generated and digitally signed by the authority (what we call a Security Token Service (STS)) your APIs trust. They require signed JWTs to prevent attackers from altering or counterfeiting such tokens in an attempt to gain unauthorized access to the resources secured by the APIs. A good open source implementation of such authority is IdentityServer4 which also gives you a lot more features than just being a STS. In development mode, IdentityServer4 provides you with…

Read more
Azure, Database, Web

Using managed identities with SQL Azure Database in ASP.NET Core

We are now in a world where we want to eliminate passwords as much as possible, and Microsoft, through its cloud platform Azure, is trying to help us do that. Today, I want to show you how you can secure your SQL Azure database using managed identities so you don’t have to create any SQL Login and carry passwords around. Prerequisites To demonstrate this, I will be using the following Azure resources: Azure App Service Plan / App Service Azure SQL Server 1 Azure SQL Database Make sure you have those already created. You also will need either the Azure CLI or Azure Az powershell module. In my case, I will be using the Azure Az powershell module. Moreover, in…

Read more
Azure

Remove a directory from your Azure account

My account had a directory in Azure that I was not a member of anymore and that I wanted to remove.  You may be in a similar situation in that you have a directory in your Azure account that you don’t need anymore and you want to remove it from your account. It is now possible to self-leave a directory as show in this post. Here is the accepted answer: 1. Log into the Access Panel at https://myapps.microsoft.com In the upper-right corner, select your name. 2. Next to Organizations, select the settings icon (gear). Note: If you can’t see the settings icon (gear), widen the browser screen. The Access Panel user interface is a reactive interface that adepts to the…

Read more
Continuous Integration, DevOps

Using WebDeploy in a CI/CD pipeline with powershell

It’s cool to play around with new Tech and new stuff but sometimes you have to come back to the basics that have been working for years. I’ve been setting up the CI/CD pipeline at my work place for my team and one task consisted of deploying the generated code documentation with DocFX, to our development web server hosted through IIS. Since I had custom logic I wanted to execute, I couldn’t use the built in WebDeploy task that was provided to me. So when you are doing DevOps, PowerShell becomes your best friend. For those who are struggling to install WebDeploy in IIS (8+), follow the guide Inigo Montoya put together. You should also configure a site using a Non-Administrative user…

Read more
C#, WebApi

Testing SignalR in ASP.NET Core with Integration Tests

As promised in my last post, I’m following up on how to test your SignalR hubs in an end to end manner using TestServer. This post is a build up on my last post so if you haven’t read it, go do so now! Setup I have a Hub named ChatHub that has the following method:

My clients all are connected to (listen to) a method to receive messages called  OnMessageReceived. Tests In my test class, I created a method to help me start my connection. If you plan on testing multiple hubs, you may want to move this method to a helper class.

Dom, my Hubs are protected with a Jwt Token… No worries, you can pass your…

Read more
C#, WebApi

Testing a WebAPI in .NET Core with Integration tests

NOTE: This posts targets ASP.NET Core 2.X. If you are looking for ASP.NET Core 3.1, see my repository. I’ve also made a NuGet package for easier consumption. You finished developing your API, and you are ready and eager to push it to production. You then realize that you are missing some tests to make it a real production ready API. Lucky for you, ASP.NET Core 2.X provides us with an In-Memory HTTP Server (TestServer) to help us achieve this. This post aims to help you write end to end tests (e2e) using ASP.NET Core 2.1 (and possibly future versions!) in order to test the flow of your API. Remember that having tests in place, whether they are unit or end to end,…

Read more
Azure, C#, Web

Connecting Azure AD and Azure AD B2C to IdentityServer4

I’ve been playing with IdentityServer4 lately and I wanted to share you guys the findings I’m finding while I am playing with it. IdentityServer4 for the ones who don’t know it, is an OpenID Connect and OAuth 2.0 framework for ASP.NET Core 2. You can read all about it here. In today’s post, I would like to show you how you can connect Azure AD and Azure AD B2C to IdentityServer4 as external providers. When doing so, IdentityServer becomes a federated gateway. Both implementation are similar, however, Azure AD and Azure AD B2C have specificities that are particular to them. Connecting to Azure AD We can connect Azure AD to IdentityServer through an external OpenIdConnect provider. To do that, you…

Read more
Azure, C#, Visual Studio

The moment I came to play with .NET Standard 2.0 – Azure Functions

A lot has changed ever since I played with Azure Functions and .NET Standard 2.0. If you remember from my previous post, I was talking about how you had to set the FUNCTIONS_EXTENSION_VERSION to beta in order to benefit from the new runtime. I also talked about how I had a problem with the connection manager to access the app settings. Well the good news is that the team now fully migrated to the new Configuration modeling from ASP.NET core. You can now easily refer to your configurations by importing the following packages and using the following code to have access to your configuration: Nuget package Description Microsoft.Extensions.Logging Main logging package Microsoft.Extensions.Logging.Abstractions Makes SetBasePath() available Microsoft.Extensions.Logging.Json Makes AddJsonFile() method available…

Read more
C#, Web

ASP.NET Identity for your custom user and roles models

I’ve been seeing a lot of requests by developers in the past months who seem to be struggling with adding their custom user authentication model into their application; they want to be able to integrate it into the ASP.NET pipeline to play nice with the Authentication middleware (i.e. AuthorizeAttribute). ASP.NET Identity Core has been rewritten to leverage the use of interfaces (abstraction!) so you can easily develop a system that caters to your needs. In this post, I want to show you how to leverage that by using ASP.NET Identity in an ASP.NET Core 2.0 application. Setup The first thing is to add the ASP.NET Identity package to your project. In Visual Studio 2017, you can right click on the Dependencies…

Read more
Azure, C#

The moment I came to play with .NET Standard 2.0 part 2!

So I’ve been on a mission to get all my pieces from my last post to work. While configuring my Continuous Integration (CI) pipeline for my bot, I’ve came across an error that made my CI build fail:

What? My project compiles fine on my computer and I thought that .NET Framework 4.7.1 had built-in support for .NET Standard 2.0. Well according to this GitHub issue something ain’t quite right yet. Adding the reference <Reference Include=”netstandard” /> directly into the csproj fixes the issue (thanks techaimail!) Azure Functions 2 Azure functions 2 (using the .NET Standard 2 framework) is still in preview (beta). So when you deploy your function through your CI/CD pipeline, make sure to go in the Application…

Read more
Azure, C#

The moment I came to play with .NET Standard 2.0…

I’ve been playing around with Azure Functions, the Bot Framework and the .NET Standard 2.0 framework recently and I’ve come across some quite interesting challenges that I want to share with you. I’ve been developing a system that has the following layout: As you can see, I have an Azure Function (Time Trigger) that pushes data to an Azure SQL database. I have an ASP.NET Core Web API (targeting the .NET Core 2.0 framework) that is the data abstraction for anything that wants to consume my data. Right now, only the Bot (Bot Framework) is the client. To have a functional and reusable ecosystem, I created some libraries to interact with my system which includes the Data Access Layer (DAL), …

Read more
C#, Software Architecture, WebApi

Web APIs: The real existential questions

The real existential questions I was talking to my buddy Alexandre about Web APIs and we had a great general discussion on the subject. What he made me realize and what I want to bring up with you guys is that building APIs goes beyond the technical implementation. Sometimes you have to look at things from a higher point of view. He shared with me with the following questions that I found very interesting. How do you project your backend API? How do you protect your core business systems? How do you enforce your IT and business policies? How do you engage with developers? How do you reduce the time-to-first API call? How do you measure their use and impact? Before…

Read more
C#, Web, WebApi

Web APIs: what you should not forget

In today’s day and age, you probably have heard of (REST) Web APIs as the way to consume data over the web. This is especially true with the emergence of microservices. You are probably building, have built or thinking of building a/some Web API(s). You are or may be planning to consume a/some Web API(s). In this post, I want to highlight certain things not to forget, on a technical stand point, when consuming and building Web APIs. Remember that those are just a start. There are multiple resources on the internet to help you adopt good practices. A good one that I recommend is the Microsoft API Implementation guide. TL;DR In building APIs: Versioning Verbs to nouns Status codes overload…

Read more