Continuing on from a previous post, this article details my journey in upgrading a Service Fabric multi-tenant application from .NET Core RC1 to RC2, which turned out to be a breaking—albeit worthwhile—change, specifically for the Startup.cs class and related boot strapping code for Swagger, CookieAuthentication, OpenIdConnectAuthentication, and JwtBearerAuthentication. In subsequent articles, we’ll explore how .NET Core RC2 hosts web applications but for now, let’s look at the first challenge encountered during the upgrade, which was to chase down all required libraries that are also .NET Core RC2 compatible.

As of the time of writing, I could only get Swashbuckle version 6.0.0-beta9 to work with .NET Core RC2.

The below code supports multi-tenant Azure AD authentication and is meant for development scenarios as ValidateIssuer and RequireHttpsMetadata are both set to false for simplicity.

The full dependencies section of your project.json should look something like this:

using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json.Serialization;
using System;
using System.Net;

Having sourced the relevant libraries and compatible versions, it’s now time to turn our attention to the ConfigureServices method wherein we’ll set up Swagger, tweak JSON formatting for JavaScript clients such as our Angular 2 SPA, and finally, also tweak how AutoRest generates client code. I want AutoRest to generate separate files per server side controller which is achieved through a custom SwaggerOperationNameFilter.

Concluding the changes required for the .NET Core RC2 upgrade, we dive into the Configure method. Canny readers will notice that UseCookieAuthentication, UseOpenIdConnectAuthentication, and UseJwtBearerAuthentication have been refactored to handle options in a more consistent manner with the rest of the .NET Core APIs.

If you’re wondering why I left the Microsoft.IdentityModel.Clients.ActiveDirectory library at “3.9.302261508-alpha”, in upcoming articles we’ll detail a strategy for automated integration testing of your .NET Core APIs using xUnit and optionally a BDD approach (SpecFlow).