CI and CD Hands On Lab with VSO Build vNext and Release Management


DEVHOL208 - Implementing Continuous delivery with Build vNext and Release Management

From the Project Unicorn story: 0 to Continual Deployment….A DevOps Story

In this lab, you will learn about the enhanced Release Management for Visual Studio Online that automate the deployment of applications across the desktop, server, and the cloud. Release Management helps development and operations teams to configure and automate complex deployments of their automated builds to target environments more easily. Development teams can also model their release processes and track approvals, sign-offs, and visualize their release status.            

    1. Show how to set up Continuous Integration from a Visual Studio Online Git repository to an Azure Web package.
    2. Show how to set up Continuous Deployment from a Visual Studio Online CI build to an Azure Web Application.

Prerequisites:

· Visual Studio 2015RC. at TechReady this will provided with as a Virtual Machine

· Azure SDK 2.6 for Visual Studio 2015 RC

· An active Azure subscription

· An existing Visual Studio Online account with a Git repository containing the solution code

· Project Admin rights to the Visual Studio Online account.

 

Steps for completing the labs

 

Parts 1. Setting up the environment for Continuous Integration

 

Step 1. Setting up the prerequisites.  In addition to Visual Studio 2015 RC you will also need the Web Platform Installer:

http://www.microsoft.com/web/downloads/platform.aspx

image

Step 2. Getting started with the standard steps for getting started with GIT

If you are at TechReady and want to use our account the the instructor will need to give you the account for access e.g.

Unicorn1@partsunlimited.onmicrosoft.com

image

Step 3.  IF YOU ARE USING YOUR OWN VSO Account:

Navigate to: https://github.com/Microsoft/PartsUnlimited/tree/aspnet45

and download the sample as a zip (or you can clone repo directly)

image

For this lab is IMPORTANT THAT YOU GET THE 4.5 BRANCH!

Step 4. IF YOU ARE USING YOUR OWN VSO Account:

When unzipping be sure and “Unblock” the content or the deployment scripts won’t run

image

Step 5. Or you can clone the entire repo and all the branches directly from the share on GitHub: https://github.com/Microsoft/PartsUnlimited.git

 image

 Step 6. Create a local branch so you aren’t working in master. Click on branches in Team Explorer>Right click on Master >New Local Branch From…

If you are using the TR account please name the branch something with your email address so you will remember it.

clip_image002[11]

If you cloned the GitHub repo it will look like the following:

image 

Step 7. If you are prompted for checkin credentials do and click update

image

Step 7. Open the PartsUnlimited.sln solution by double clicking on it….You can verify it is opened by manually switching to solution explorer –but there is no need

clip_image001

Step 7. If you get the error: This version of Visual Studio is unable to open the following projects

Then you didn’t install the Azure 2.6 SDK…please go back to step 1 of this lab.

For more information please see:

http://blogs.msdn.com/b/charles_sterling/archive/2015/06/17/this-version-of-visual-studio-is-unable-to-open-the-following-projects-deployproj.aspx

(Yes we are getting the documentation updated!)

image

 

Step 8. Make sure and publish the branch back to VSO so the build definition can see this branch.

If the option is grayed out like in the screen shot you have not created the local branch

Make sure and publish the branch you created!

image

Step 9. Right-click the PartsUnlimitedWebste project and then BUILD to pull down all the Nuget packages and everything is ready for creating the build.

 image

Step 10.  If you try running the application locally and see this error:

An exception of type 'System.Data.SqlClient.SqlException' occurred in mscorlib.dll but was not handled in user code

It means you don’t have SQL Server installed locally.

image

 

Creating the Infrastructure for your Web Application (config as code)

Waiting on David/Brian to get automation working

 Step 1.    In a PowerShell prompt run: Set-ExecutionPolicy RemoteSigned

 image
Step 2.    In solution explorer select the PartsUnlimitedEnv project. 
Step 3.    Right click choose deploy and
“New Deployment….” 

clip_image002[13]

Do NOT click Deploy YET!

Enter values for the PartsunlimitedDBName and webSiteName parameters.

image

If you are using your own Azure subscription these need to be globally unique.  If you are using the Partsunlimited Azure Subscription please resuse the name PartsunlimitedWeb.

image

22.    Enter a complex password for the ServerAdminPassword parameter
23.    Click Save and then Deploy.

You may be prompted for the password…if so please enter and press okay.

image

Please note this may take a while. Please wait for the output windows waiting for the message: “Successfully Deployed”

 

Creating the Publish Settings

Step 1. Now that we have the Azure infrastructure created it is time to create the publish definition that we will use to create the Azure Web App Package and use to publish to the Azure Web App. The first step is to right click on the project and select “Publish”

image

 

Step 2.  Select to option to publish to a “Microsoft Azure Web Apps”

image

Step 3. Select the Web Application you created in the “edit parameters” section above, where you specified the parameter name “Website”

…or if are you using the PartsUnlimited Azure Subscription select PartsUnlimitedWeb

image

Step 4. Verify the publish method is “Web Deploy”

image

Step 5. Verify the database connection created in the infrastructure deploy was correctly picked up.

If we didn’t you can manually reference a DB that was created earlier:

Data Source=partssprint1.database.windows.net,1433;Initial Catalog=PartsUnlimitedDB;User ID=AdminUser;Password=P2ssw0rd

 

image

 

Step 6.  At this point you manually deploy the Web Application…this will also save the PartsUnlimitedweb.pubxml file.

You can verify the success of this manual publish by viewing the website at:

http://partsunlimitedweb.azurewebsites.net/

image

Step 7. Go to Team Explorer > Changes scroll down to Untracked Files and add the publish definition you created…by default called PartsUnlimitedWeb.pubxml

While you are in untracked files section of the Changes dialog you should verify the Partsunlimited.sln has been correctly referenced. It is likely the Partsunlimited.sln file wasn’t included-and is needed for the next section.

image

 

Creating the CI Build

Step 1.  Now that the project is building, checked in and the infrastructure is created it is time for the easy part…creating the build. Log into a Visual Studio Online Account…If you are at TechReady and the proctor has added you to the shared VSO account this account will be:

https://partsunlimited.visualstudio.com/

image

Step 2. Navigate to the ILLTR team project by clicking the “Browse” link.

image

Step 3. Select the “Build” Menu. 

NOTE Build.Vnext and Build has been merged you will NO longer see the build Build.Vnext as a separate option.

The legacy builds are now called XAML builds and new builds are simply called just “Builds”.

image

 

Step 4. Create a new Build. Click the Action button (Green Plus) to create new build definition

Please name this with your email address so you can find it later

image

Step 5.  As you can see, you can now do Xamarin Android/IOS and Builds as well as Xcode builds. Click on Visual Studio Build under the Build tab on the Definition Templates dialog.

image

Step 6. As we have multiple repos and branches, so we need to select the correct Repo and Branch before we can select which Solution to build.  If you had created a branch Click on the Repository tab and Select the repository you created above. If you didn’t create a repo just select Master for the Default Branch

Note Add circle around the right drop down

image

Step 7.  Now we’re going to select the solution we’re going to build.  Click on the Build tab and Click the ellipsis in the Build Solution pane and select the PartsUnlimited.sln file.

image

Step 8.  There is an issue in Visual Studio 2015 RC and 2013 Update 5 that SLN Files are not automatically added to the files that are included in version control for Git that is getting fixed for the release.  If you don’t see the Partsunlimited.sln file go back to Visual Studio > Team Explorer > Changes. Scroll down to Untracked changes and add the PartsUnlimited.SLN, checkin, and sync the changes

image

Step 9. Configure the build definition to build the Publish package. This is done by specifying an msbuild argument

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"

image

Step 10.  So that the Build fires off every time there’s a check in, enable the Continuous integration trigger. You can select which branch you wish to monitor, as well. On the trigger tab of the build definition select “Continuous Integration”.

image

Step 11. Save the build with a name containing your email address that you will remember

image

Step 12. Test the CI Trigger.

1. In Solution Explorer, open PartsUnlimitedLite/Views/Home/index.cshtml

2. Make a small but visible change, e.g. in the <h1> title text.

Save the file

image

Step 13.   Check in the change

1. Open Team Explorer

2. Click the Home button

3. Click the Changes button

4. Enter a Commit message

Click Commit

image

Step 14.  Sync changes back to the server.  In Team Explorer, click the link to Sync changes back to the server

Click the Sync button to perform the sync operation.

image

Step 15. In the PartsUnlimited.Visualstudio.com under the build.vNext tab, you will that the CI build had been queued.

image

 

Step 16 Let’s see how the build is doing. You can see the Build steps and the details in this panel.Double click on the queued build.

2. Monitor the build process and confirm that completes successfully. 

 

 

image

 

Continuous Deployment from a Build

NOTE THIS MUST BE CREDENTIALS NOT CERTIFICATE….need to change!!

If you wanted to deploy the web site from you CI build (in many cases not recommended) you can.

For mainstream workflows please skip to the following section to see how this is done from a CD Pipeline.

Step 1.  As we will be using Azure we need to add Azure Subscription steps

image

Step 2.  Add the deployment step. Click on Add Build Step…Scroll down and click Add on the Azure Web Site Deployment step. Then click Close. Click on the Azure Web Site Deployment step

image

Step 3. Configure the deployment task. Select the appropriate Azure Subscription to use for the deployment.  Enter Partsunlimitedweb for the Web App deployment slot (this should match what is currently in the Azure Webapp).  Enter <Web Site Location> where the Web App resides. For the Package location, enter the following:

$(build.sourcesDirectory)\PartsUnlimited-aspnet45\src\PartsUnlimitedWebsite\*.zip

 

image

Step 4. Test the build

Step 12. Test the CI Trigger.

1. In Solution Explorer, open PartsUnlimitedLite/Views/Home/index.cshtml

2. Make a small but visible change, e.g. in the Tire description add new line.  (like Slippery when wet)

Save the file

image

 

 

Step 13.   Check in the change

1. Open Team Explorer

2. Click the Home button

3. Click the Changes button

4. Enter a Commit message

Click Commit

image

Step 14.  Sync changes back to the server.  In Team Explorer, click the link to Sync changes back to the server

Click the Sync button to perform the sync operation.

image

Step 15. In the PartsUnlimited.Visualstudio.com under the build.vNext tab, you will that the CI build had been queued.

image

 

Step 16 Let’s see how the build is doing. You can see the Build steps and the details in this panel.Double click on the queued build.

2. Monitor the build process and confirm that completes successfully. 

 

 

image

Verify the change made it to the site:

image

 

Setting up a continual deployment with Visual Studio Release Management

Now that we have our CI build working and creating the Web Deploy package. It is time to get set up continual deployment in a release pipeline.  Note: at the time of authoring this document Release Management was not available publically in VSO….you may have to use this shared account even if you are at Techready to see these features. 

Step 1. In Visual Studio Online click on the Release Hub. Note: if you don’t see you “Release” in your Visual Studio Online account it is due to the fact it is still hidden with a feature flag and you will have to have the lab proctor add you to the PartsUnlimited VSO Account. 

image

Step 2.  Click the Action button (Green Plus) to create new release definition

Please name this with your email address as it is likely we will be creating lots of release!

image

Step 3. The stereotypical dev team will have three environments…lets create those.  Click the Action button (Green Plus) for environments twice…giving us a total of three environments. 

Name the environments:

a. Dev

b. QA

Prod

image

Step 4.   You will note there are lots of options for running Tests as part of the build.  Lets set that up:

1. Select the “Dev” Environment

2. Click the Action button (Green Plus) for tasks (see image above) select the “Test” category and add a task that runs all unit tests in the solution on the build controller.

image

Step 5. Setup up the Test task…while there is no specific actions here it is worth reviewing the options for running tests…

image

Step 6. Add Approvers to the QA Environment step of the build release.

10. Add Approvers to the Pre-deployment stage of the QA –Environment.

NOTE: Make and sure and the account you are logged in with or you will have to reassign the approver to complete this build

image

Step 7.  Add task and go to the “Test” category

image

Step 8. Add Load Testing to the QA Environment

http://blogs.msdn.com/b/visualstudioalm/p/cltbuildtaskhelp.aspx

image

Step 9. Save the Release Definition

image

Step 10. If you cannot save the release make sure the account is in the release managers group.  To add your account to the Release managers group click on the gear.

image

Step 11. Click on Security tab.

image

Step 12. Select Release Managers > Members > Add and add the account you are logged in with

image

Step 13.  To reference the build we created above you must create an artifact in release management. Click on Artifacts

image

Step 14. Click the Action button (Green Plus) to create new artifact

image

Step 15.  Give the artifact a name and specify you want the entire build by adding a “\” for the path

image

Step 16. Deploy into Production $(build.sourcesDirectory)\PartsUnlimited-aspnet45\src\PartsUnlimitedWebsite\*.zip

image

Step 17.  Now that all the components of this release pipeline are completed it is time to set it to run on the completion of a build. Click on Triggers

image

Step 18. Check the check box for continuous deployment and select the build you created above

image

Step 19 As a test it is probably worth verifying your release pipeline will work when started manually.  Click the Action button (Green Plus) to create new release.

image

Step 20. This will prompt you which build do you want to run the release on…Choose a build and select “Create”

image

Step 21.

image

 

Step 22. Check the status (pending)

image

Step 23. If you remember earlier in the lab, the release

Has an approval step in it.  Select the release hyper link you just created above and select “logs”

image

Step 24. Approve the release to the QA environment

image

Step 25.

image

Step 26.

image

Testing in Continuous Integration and Continuous Deployment Workflows

At a high level DevOps is a focus on increasing customer value by reducing cycle times in the development process.  As a result of these faster cycle times testing as part of the DevOps workflow can be challenge. This section will look at integrating testing into CI/CD pipelines using to ensure less friction in the testing process and a high quality application.

Step 1. Creating a machine group.  Due to time time considerations in this lab we will reuse a Test Machine that already exists but as this corner stone of the Testing CI offering please open the Test hub and the “Machines” menu.  Select the Test CI machine group and select edit.

image

Step 2.  Adding Machines to a machine group.  In this dialog you can see how computers would be added to a machine group.  This enable testers to very easily run the same test against multiple machines. 

image

There several caveats for computers to be access with this early version of the Test CI agent and workflow.

  1. We do not have the support for test machines residing in Azure yet. However this is coming soon.
  2. The build agent and test agent machines should be on-premises machines and the build machine should be able to communicate with the target test machine.
  3. The build agent being used for the Test CI tasks must be domain joined
  4. The computer being added the machine group must be domain joined
  5. Need to enable winrm on your test agent machine (winrm quickconfig)
  6. We do not support use of the “hosted” build pool for the Test CI tasks
  7. Do not install test agents for visual studio 2015 on a machine with VS2015RC.  There is known issue here that we have fixed for RTM.

Step 3. Edit the release definition to Add the Test CI Tasks to the CD Pipeline.

image

Step 4. Add the Test CI tasks

While this is shown in the CD pipleine

 image

 

Step 5 Configure the Deploy Agent step

image

Step 6 Configure the run with Agent

 

image


Comments (0)

Skip to main content