Zero to DevOps

This is a write up of Donovan Brown’s VS Live 2016 Zero to DevOps. In this post i am gonna show you how to go from “zero to DevOps” like a pro with DEV, QA & PROD environments for ASP.NET MVC application that we’re gonna deploy to azure. I am gonna do in a resource group called “e2eDemo” on Azure.

Pre-requisites-

1. Active Azure Account
2. VS 2015 ( Any edition )
3. VSTS Account

Let’s begin with a blank desktop as you can see nothing is running on my windows dev box as shown-

1

Will start by creating an VSTS account for this demo by navigating to http://www.visualstudio.com as shown below-

2

Sign in to the portal using your Outlook, Hotmail etc and click on create new account. You should be able to see the below window-

3

Give a suitable name for your account and you could choose one of our source control repositories to manage your code. In my case i will be using Git. Post the creation, you’ll be redirected to your account dashboard as shown-

4

Go to the code hub, scroll down and if you want to create a readme file for your project you could pretty much do that as well.

5

Once created, you should see a readme file in your repo-

6

You can edit the file and do some changes just to give a valid name for your readme-

7

I have edited the first line and looks something like this-

1

Once saved, let’s try to setup a build definition. Click on the setup build at the top right corner-

9

A new popup would appear to select the build templates for you to define your build workflow. So lets go to the deployment hub and select Azure Web App since we would be deploying it to azure-

10

Select the repo and enable Continuous Integration. At this point you can set up your own private build agents or use the hosted agents provided by Microsoft. I would go with the hosted one at the moment-

11

You should see the build pipeline as shown-

12

Since we are embracing complete DevOps, we will remove the “Deploy” task from the build as we would be doing it from the release. Post which you should see as shown below-

13

Navigate to the “Test Assemblies” task and check code coverage-

14

Navigate to the options tab and check “create work item on failure” and select the “bug” as your WIT type. Since we are performing CI build, it has a tendency to fail. It’s good to have the WIT on failures so that it forces developers to go and fix particular issues-

15

At this moment let’s save our build definition as CI.

Navigate to work hub where we can plan. Create a PBI something like this-

16

Now let’s breakdown the PB to tasks which are individual items that we are gonna complete to turn the idea into a working piece of software-

17

Navigate to Kanban board,create 1 more task and re-order it by just dragging it to top-

18

You should be able to see the task 1st which you re-ordered. Move the PB from “New” to “Active” and the assigned to gets automatically assigned to yourself-

20

Now let’s branch from the work item so that we can have our isolation without polluting the other branches-

21

I have created a branch called “Init”-

22

Click on clone which brings you the tools that you can work with. Select Visual Studio and it should fire up you one-

24

You should see the VS with the repository cloned for you-

25

Go to the branches, expand remote origins and double click the “init” branch. At this moment you would have checked out your branch so that you can actually go and do your work in isolation. At the bottom right corner, you can see the branch you are currently checked out-

26

Navigate to Your Azure Portal to make sure that you don’t have a resource group at the moment-

23Click on new under solutions to create a new project-

27

Go to web and select ASP.NET template. Select your azure subscription at the right side and also configure application insights-

4

After clicking on configure settings for application insights, a pop up would appear. Fill the details as shown-

2

Click on OK and you should see this page. Select MVC, add unit tests at the bottom and also change authentication to “No authentication” as shown-

30

Once clicked, you will land at creation of App service plans, resource groups etc. Click on New to create a new resource group. Click new to create a new App service plan and click create. You should see something like this finally-

7

Once done, you should see a sample asp.net application being created from your visual studio-

8

Navigate to your azure portal to make sure you have the resource group along with couple of resources created and running for you. Add web-apps for QA and Prod. Click on add, select the webapp and give the name for your site. Repeat the steps for adding PROD site as well.Finally you should see all the websites ready for our deployment process under the resource group-

12

Let’s go and add webapps for QA and Prod. Click on add, select the webapp and give the name for your site. Repeat the steps for adding PROD site as well-

Now let’s put in the code so that we could have our build and deployment done. Go to the changes and commit and push the code-

41

At this moment you could see that we have pushed our code to the “init” branch which we had created earlier. But the CI build is in the master branch for which we gotta merge the code from init to master through pull request. Create a new pull request as shown-

42

You will be redirected to the web portal of your vsts account.

44

Click on “New pull request” and complete the pull request. You can give suggestions, add approvers and do lot more-

45

Next click on complete merge to complete the merge process from init to master branch. You can delete the init branch which was created earlier post the merging operation by simply selecting the checkbox at the bottom-

45_001

You should get the successful completion of pull request-

47

Navigate to the build hub to see the CI running-

48

You should see a successful build.

50

Note- If there were any failures in the build, then nothing to panic. Just go to solution, right click on “ApplicationInsights.config file” and “Add ignored files” then checkin to the repo. You should have a successful build and voila-

Now it’s time for the deployment and let’s create a release from the build summary itself as shown-

52

Upon clicking on create release from the bottom of the build summary, you will get a popup to choose the template. Select “Azure Website deployment” and click next-

53

Select the build definition and enable continuous deployment and click next-

54

You should see the release definition as shown-

55

Lets remove the “Run tests” task and configure Deploy website to azure task. Click on manage-

56

Add endpoint “Azure Resource Manager”. Provide a name and select the azure subscription that you wish to deploy-

58

In the task, select the subscription and app service name-

9

Let’s clone the environments for QA and prod. Click on the ellipse and clone-

60

You can set the approval workflow levels by adding yourself-

62

Repeat the steps for PROD environment as well.

Create a release, and you should be able to see the successful releases-

13

Login to the websites (DEV, QA and Prod) and you should be able to see the app running with the code deployed-

10

Also you can check the app insights in azure portal which was configured earlier-

14

Hope you enjoyed 🙂

Thanks,
Srivatsa

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: