Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

Latest commit

 

History

History
201 lines (135 loc) · 8.13 KB

exercise06.md

File metadata and controls

201 lines (135 loc) · 8.13 KB

Exercise 6

Learnings

  1. Basics about Visual Studio Team Services
  2. Committing code to VSTS using Git and Visual Studio
  3. Setting up automated build
  4. Connecting VSTS and Azure
  5. Setting up VSTS Release Management

Create Visual Studio Team Services Project

  1. Discussion points:

    • Brief overview about Visual Studio Team Services (high-level features, relation to TFS, pricing models, etc.)
  2. Navigate to Visual Studio Team Services (VSTS) and create a new subscription if you do not already have one.

  3. Navigate to your VSTS subscription. In my case the URL is https://rainerdemotfs-westeu.visualstudio.com/. Replace this URL with your personal VSTS URL.

  4. Create a new VSTS project PracticalDevOps. Make sure you select Git for Version control.
    New VSTS project

  5. Navigate to your new project.

Commit Code to Visual Studio Team Services

  1. In Visual Studio's Team Explorer, select Connect to Team Project.
    Connect to Team Project

  2. Add your VSTS server and select the PracticalDevOps project.

  3. Clone the project to a new local directory.
    Clone project

  4. Copy the code your created in the previous exercises into the new local directory.

  5. Copy the .gitignore file from Exercise-6-VSTS-Source-Control into the new local directory.

  6. Discussion points:

    • Overview about functionality of Visual Studio's Team Explorer
    • Point out that VSTS works with any Git client (e.g. demo git CLI or Git Extensions)
  7. In Visual Studio's Team Explorer, goto Changes, review the changes that Visual Studio has detected (see image below), and commit your changes.
    Commit Changes

  8. Take a look at the committed code in the VSTS portal.
    Code in Portal

Setup Build

  1. Click on build setup now in VSTS.
    Setup Build

  2. Accept the suggestions of the Build Setup Wizard.

  3. Discussion points:

    • Speak about how branches, build processes and deployment slots can be used for dev/test/prod
    • Build process walk-through
    • Overview about additional build steps that would be possible
    • Describe concept of cross-platform build agents
  4. Add the following arguments to MSBuild in step Visual Studio Build (necessary for creating the Web Deploy package): /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"
    MSBuild Arguments

  5. Save the generated build definition with the name PracticalDevOps Build

  6. Setup Continuous Integration (CI) by creating a trigger.
    Continuous Integration

  7. Queue a new build.
    Queue Build

  8. Watch how the hosted build controller builds your code. You should not get any errors.

  9. Take a look at the build results.
    Build results^

  10. For testing purposes, screw up tests (e.g. by removing the Ignore attribute from test IgnoredTest), check your changes in, and see the build failing. Remember to fix your code again so that you can continue with the rest of the exercise.

Setup Release Management

  1. In VSTS project options, goto Services area. Add a service endpoint for Azure
    VSTS Services

  2. Select Certificate Based and follow the link download publish settings file. Open the publish settings file and copy the required data into VSTS.

  3. Discussion points:

    • Point out security-related issues with handling publish settings files (again)
  4. In build results, follow the link to create a release.
    Create release

  5. Discussion points:

    • Describe concepts of VSTS's release management
    • Release process walk-through
    • Overview about additional steps that would be possible
  6. Setup deployment to Azure Web App.
    Azure Web App Deployment

  7. Setup Continuous Deployment by creating a trigger.
    Release CD

  8. In order to automate deployment, create a Deployment Condition.
    Deployment Condition

  9. Trigger deployment automatically whenever a release has been created.
    Trigger deployment

  10. Now you can test the entire pipeline. Change someting in your code (e.g. appending a ! to the title) and check your code in. The build should be triggered automatically. The release should be created after the successful build. The release should be immediately published to Azure App Services.

Run Load Test in VSTS

  1. Discussion points:

    • Describe advantages of load testing in the cloud
  2. Right-click on solution and add new Test Settings named Cloud.
    Add new test settings

  3. Change test settings to Visual Studio Team Services.
    Change test to VSTS

  4. Activate new VSTS test settings.
    Activate test settings

  5. Change load test from Test Iterations to Run Duration as VSTS does not support test iteration setting.
    Change to run duration

  6. Set load test location.
    Set load test location

  7. Set load test location.
    Set load test location

  8. Select the test location you want to use (ideally the location where you deployed you web app to).
    Select load test location

  9. Run load test.
    Run load test

  10. Watch load test running in the cloud. Analyze load test results in Visual Studio and in Visual Studio Online (web report). Test test will probably fail.
    Failing load test

  11. Discussion points:

    • Discuss the consequences of this result (our app has a scalability problem)
    • Use Application Insights (see also exercise 4) to detect the source of the problem (requests to Blob Storage start to fail after a certain period of time).
    • How could we gather more detailed exception information?
      Add OWIN unhandled exception handler that logs to Application Insights.
      Detailed exception message in AI
      Here is the necessary code (only recommended in a rather dev-oriented audience):
         namespace Books
         {
             public class Startup
             {
                 private class AiExceptionLogger : ExceptionLogger
                 {
                     public override void Log(ExceptionLoggerContext context)
                     {
                         if (context != null && context.Exception != null)
                         {
                             var ai = new TelemetryClient();
                             ai.TrackException(context.Exception);
                         }
      
                         base.Log(context);
                     }
                 }
      
                 public void Configuration(IAppBuilder app)
                 {
                     // Configure and add Web API
                     var configuration = new HttpConfiguration();
                     ...
                     configuration.Services.Add(typeof(IExceptionLogger), new AiExceptionLogger());
                     app.UseWebApi(configuration);
                 } 
                 ...
             }
         }
      
  12. In the web test's request properties, set think time to five seconds.
    Set think time

  13. Re-run load test. Now it should succeed.
    Run load test

Further Ideas

If you have time left, you could additionally cover topics like:

  • Setup an additional build agent in a VM