Hopefully I covered all the hipster development terms in that title. In this series I am going to walk you through the process of creating an API using .NET Core 2.0 and VS Code and pushing to a GitHub repository. From there, I’ll show you how to set up continuous integration and deployment using Visual Studio Team Services and then how to deploy to a Azure Container Instance.

Use the links below to follow along:

CI/CD with .NET Core 2.0: Intro (this post)

CI/CD with .NET Core 2.0: Visual Studio Team Services

CI/CD with .NET Core 2.0: Docker

CI/CD with .NET Core 2.0: Deploying to Azure

The source code for this project can be found here

The API

What does the world need? What would make the biggest impact to humanity? A number trivia API! Our API will expose interesting tidbits about a specified number. Being a good developer and not wanting to reinvent the number trivia wheel, I found an API that does provide this functionality. Yo dawg, I heard you wanted an API wrapper for that already easy to use API.

I’m using Windows 10 for development but the process will work cross platform thanks to .NET Core and Obama (Ok, just .NET Core).

Source code can be found on GitHub

Let’s get started!

.NET Core 2.0 Install

If you haven’t installed .NET Core 2.0, take a minute (or 5) to do so now. Super clear instructions can be found here. There’s instructions for Windows, macOS, Linux, and Docker.

Once installed, open a command prompt and enter the following to verify that the installation succeeded:

dotnet --version

You should see 2.0.0

We’re good to go! Let’s move on to creating the API

API Creation

From the command prompt either navigate to or create the folder where you want to create the API. I’m creating the API in a folder called c:\DemoProjects

umbertrivia . Within the numbertrivia folder, I’ll create two other folders: api and tests because we’ll actually write integration tests <gasp>!

Issue the following command to create the API project within the api folder

dotnet new webapi

This will create the project, restore any NuGet packages and build the project.

Issue the following command to create a new Xunit project within the tests folder

dotnet new xunit

Let’s go ahead and create the git repo and push to GitHub. I’ll add a .gitignore file to the main numbertrivia folder. You can grab one here. Follow the commands in the image below to set up the repository.

You can follow the steps in the image to initialize a Git repository and then commit both projects and push them to GitHub.

VS Code

At this point, let’s open the project in Visual Code so we can begin coding. You can either manually launch it or use the convenient shortcut code . in the command prompt.