From Soup to Nuts: Azure DevOps with Visual Studio 2017

This is the introductory post in a four part series walking through the process of creating a project in Visual Studio and building out a complete CI/CD pipeline to get that code into production on Azure using Azure DevOps.

Here’s a rough outline of where I think this series will go. As soon as I have the content ready I’ll link to them from here:

Part 1: Publish to an Azure DevOps Repository

Part 2: Setting up a Build Pipeline in Azure DevOps

Part 3: Setting up a Release Pipeline in Azure DevOps

Part 4: Adding a Database to the Project

A little context… Lately I’ve been using the Eclipse plugin Subversive for source control on my java-based projects, which uses an on-prem SVN server. For C# projects I use the Visual Studio plugin VisualSVN. Back in the old days I used an on-prem TFS server. Before that VSS which I’ll just leave that right there. So I’ve used SVN for many years and I have no complaints about it in particular or concurrent version control systems in general. But this series isn’t about those tools or centralized version control. And it’s not about Git Bash or shelling out to the command line from GitHub Desktop or anything like that.  Download the Pro Git book if you want to dive deep into that area. 

I’ve also used TFS v1.0 and before that NAnt and then CruiseControl somewhere along the line. Currently my place of work uses TeamCity for builds, NUnit for tests, Octopus for deployments and probably other things like DbUp for database scripting. And I’ve deployed straight to Azure from Visual Studio more times than I can count. But guess what? This series isn’t about any of those things either. In this series I want to help you to take your game up to the next level so that your pipeline to production is fully automated. And I want to keep it as simple as possible. So let’s get started at Part 1.

Part 4: Adding a Database to the Project

This is Part 4 in a  series on Azure DevOps.

In  Part 1 I created a simple web app called WidgetApi. I then put it under source control and pushed it up to an Azure DevOps repo. In Part 2 I configured a build pipeline and made a code change to trigger that build with continuous integration. In Part 3 I set up a release pipeline and deployed our build artifacts to Azure. In this part I’m going to add a database to WidgetApi and use a DACPAC file to bundle database changes for deployment in the release pipeline. Finally, I’ll configure a production environment with an approval process.

Continue reading “Part 4: Adding a Database to the Project”

Part 3: Setting up a Release Pipeline in Azure DevOps

This is Part 3 in a  series on Azure DevOps.

In  Part 1 I created a simple web app called WidgetApi. I then put it under source control and pushed it up to an Azure DevOps repo. In Part 2 I configured a build pipeline and made a code change to trigger that build with continuous integration. In this part we’re going to create a release pipeline that deploys our build artifacts to Azure.

Continue reading “Part 3: Setting up a Release Pipeline in Azure DevOps”

Part 2: Setting up a Build Pipeline in Azure DevOps

This is Part 2 in a series on Azure DevOps.

In Part 1 I created a simple web app called WidgetApi. I then put it under source control and pushed it up to an Azure DevOps repo. In this part we’re going to set up a build and then change our code to trigger a continuous integration build. Open the browser and go to your Azure DevOps portal. You should see all your pushed commits there from Part 1. Awesome. Now there’s a couple of housekeeping things to do before we set up the build.

Shout out to https://devrant.com/rants/1535091/ci-cd-in-a-nutshell

Continue reading “Part 2: Setting up a Build Pipeline in Azure DevOps”

Part 1: Publish to an Azure DevOps Repository

In this series I’m going to use the free Visual Studio 2017 Community Edition and the free Azure DevOps to target a full-blown CI/CD pipeline to deploy a web application to Azure.  So in addition to those tools make sure you have an Azure subscription. Last, I’ve got the latest Git for Windows installed (v2.19.1.windows.1). So let’s get started after the jump.

Continue reading “Part 1: Publish to an Azure DevOps Repository”

ASP.NET Core 2.1 Web API Using Multiple Authentication Schemes

There’s very little guidance from Microsoft on writing your own custom authentication handlers for Core 2. If you look at the documentation you’ll find detailed guidance on the built-in Core Identity model that they want you to use. They also provide links to third-party open-source providers like Identity Server which is what I use in this example. There is an article on custom cookie authentication. But generally speaking because security is hard and it’s way too easy to screw up Microsoft would rather you did not roll your own. It’s best to stick to the prescriptive guidance Microsoft offers. Now that I’ve said that I’m going to ignore completely my own advice. Read on if you’re with me.

Continue reading “ASP.NET Core 2.1 Web API Using Multiple Authentication Schemes”

Microservices with IdentityServer4 and Ocelot Fronting a .NET Core API

Well just like the title says I want to show a complete microservice-based architecture using the lightweight IdentityServer4 for authentication and Ocelot as an API gateway. Ocelot will act as a reverse proxy for a secured internal ASP.NET Core Web API. Everything here is open-source .NET Core 2.0 or later.

The main source of guidance I consulted for this architecture is the eShopContainers project and the white paper they published (which I read cover-to-cover at my favorite coffee shop and I recommend you do the same). There are a few helpful blog posts out there too. Dan Patrascu-Baba wrote a couple posts (here and here), Scott Brady wrote a helpful intro to IdentityServer4, and Catcher Wong wrote a nice series on Ocelot. But I couldn’t find a “complete picture” presentation of the whole architecture so I decided to write it myself. My goal here is to present a bare bones framework in one place to help bootstrap a serious microservices project.

I’ve organized this post into three parts: (1) The Big Picture; (2) The Configuration; and (3) The Deep Dive. Let’s get started right after the jump…

Continue reading “Microservices with IdentityServer4 and Ocelot Fronting a .NET Core API”

A Simple CQRS Pattern Using C# in .NET

For years in my apps I’ve used a Data Mapper pattern or even the Repository pattern to mediate between the business domain and the database. One thing I’ve learned is that something like this interface is no help at all:

public interface IEntity
{
    int ID { get; set; }
}

public interface IRepository where T : IEntity
{
    T Get(int id);
    IEnumerable GetAll();
    int Add(T item);
    bool Update(T item);
    bool Delete(T item);
}

In all but the most trivial app it proves too inflexible to be useful. This is because no two entities are alike. In one case calling a Get() function and passing in an ID is just fine. But I might have a two-part key for another entity. Or I might need GetByLastName() instead. So I end up adding extra functions to the concrete repository class. But If I’m adding functions outside the contract then I might as well not use the contract at all. Another problem with a non-trivial app is the repository even for a single entity quickly becomes a big ball of mud (if you’re lucky) or a God class if several developers are working together and there’s no discipline. If I have to wade through 30 fetch functions to get to the one I want that’s not maintainable. There are other growing pains that emerge a few years down the road. But others — notably Ayende — have documented those problems so I won’t rehash that here. Instead I want to describe a simple CQRS pattern as an alternative that I’ve found to be flexible and maintainable over the long haul.

Continue reading “A Simple CQRS Pattern Using C# in .NET”

Oregon Star Party 2015

The Oregon Star Party (OSP) gathers every year in August in the high desert of the Ochoco Mountains in Central Oregon. This year it was brutally hot during the day and bone-chilling cold at night. In other words a typical year. Kat and I attended again this year so I wanted to capture the experience and document some of the sketches I made. First here is a gorgeous sunset taken from our remote 5,000-foot elevation base camp:

Of course the pretty colors came at a heavy price as wild fires continued to burn over 200,000 acres throughout Oregon. The fires at the Warm Springs Reservation directly to the west of us had already consumed about 55,000 acres. The dark orange sunlight had to refract through all of that smoke settling in the distant valley.

Continue reading “Oregon Star Party 2015”

Hancock Woman Pictograph Solar Calendar

A few weeks ago I volunteered to help Bernie Taylor, a fellow member of Rose City Astronomers, to investigate whether the so-called “Hancock Woman” pictograph out near Fossil, Oregon might be a solar calendar.

Bernie wrote the book Biological Time and he was kind enough to give me a copy. I have only had time to skim it heavily at this point but I highly recommend it to anyone interested in biological rhythms and the way animal behavior changes during lunar and solar cycles in nature.

Continue reading “Hancock Woman Pictograph Solar Calendar”