Using AWS Tools for Microsoft Visual Studio Team Services

Microsoft Visual Studio Team Services (VSTS) allows you to visually define your CI/CD process straight from the management portal. You don’t need to be a DevOps hero, and you don’t need to install any DevOps related tools on your machine. If you have never set up a build process in VSTS, then you can start with this guide. VSTS is also extensible, allowing you to develop your own extensions and integration. You can get started with this article. A few weeks ago, AWS Tools for Microsoft Visual Studio Team Services extension was introducted.

The AWS Tools for Microsoft Visual Studio Team Services (VSTS) extension makes it easy to deploy .NET applications to AWS. In this tutorial, we will be deploying a sample ASP.NET Core 2.0 application to an EC2 instance. The sample application was created with the simple dotnet new command.

We will go through how to:

  • Install the extension
  • Configure the AWS Service
  • Configure the AWS CodeDeploy application
  • Create the Build Definition
  • Make the necessary changes to the Build Definition

Install Extension

Before we start with our configuration, we will need to install the AWS Tools for Microsoft Visual Studio Team Services extension. Head to the marketplace and click on Install.

Visual Studio Marketplace

The extension is now installed and we connected our VSTS account to AWS. In order to configure the service, we will need to create an IAM user in AWS.

Configure AWS Service

Before we configure the service in VSTS, let’s open up the AWS Console and create an IAM user. Once the user is created, you can mark the Access Key ID and Secret Key ID.

Create User

Configure AWS CodeDeploy

In order to use CodeDeploy, we will need to create a CodeDeploy application. Head to the CodeDeploy Management screen and create a new Custom Deployment. To keep things simple, you can choose an In-place deployment with an existing EC2 instance that you configured to run an ASP.NET Core application.

To create the EC2 instance for CodeDeploy, you can following this documentation article.

Create VSTS Build Definition

We head back to the VSTS management portal, click on the project for which we want to configure the AWS connection, and select the Services tab.

Add AWS service

Now we can configure the service with the Access Key ID and Secret Key ID of the user that we created earlier.

Service created

The next step would be to create the Build Definition in Visual Studio Team Services. We will be using the ASP.NET Core template and we will adjust the steps as needed to work with the 2.0 version.

Create build definition

Now let’s add the deployment with CodeDeploy. Click on Add Task and select AWS CodeDeploy Application Deployment.

Adjust VSTS Build Definition and AWS Tools

At the time of writing, ASP.NET Core 2.0 build support is still in preview. In the build task, set the ASP.NET Core version to 2.* (Preview). If you are not able to build the app still, you can follow the instructions in this thread. It worked flawlessly for me.

If you want to publish self-contained application, you can modify the Publish task arguments to:

--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory) --self-contained --runtime "debian.8-x64"

Now let’s set the properties on the CodeDeploy task to match the names that we set in AWS. And then drag it all the way to the bottom of the build definition.

CodeDeploy Properties

Voila, now are ready to queue our build.

Conclusion

In this tutorial, we used one of the many powerful Visual Studio Team Services extensions. We managed to create and deploy an ASP.NET Core 2.0 application to an EC2 instance in a few steps and without writing any Powershell scripts phew!

No Comments Yet.

Leave a Reply

Your email address will not be published. Required fields are marked *