Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

DevOps with Visual Studio Team Services (NodeJS)


In this lab, you will create a Visual Studio Team Services online account, check in your code, create a Continuous Integration pipeline, and test your cloud-based application.


In this hands-on lab, you will learn how to:

  • Create a Visual Studio Team Services online account.
  • Create a VSTS Git repository.
  • Add your code to the VSTS Git repository.
  • Create a Continuous Integration pipeline.
  • Deploy a built application to an Azure Web App from VSTS.


  • The source for the starter app is located in the start folder.
  • There will be no code changes required so the the end folder will remain empty.
  • Deployed the starter ARM Template HOL 1.
  • Completion of the HOL 3.

🔺 Note: If you did not complete the previous labs, the project in the start folder is cumulative. But you need to add the previous HOL's environment variables and make all necessary changes to Azure. 🔺


This hands-on-lab has the following exercises:

Exercise 1: Create VSTS online account

🔺 You can skip this exercise if you already created an account in HOL 1. 🔺

  1. In your browser, navigate to


  2. Click Get started for free link below Visual Studio Team Services.

  3. Log in with your Azure AD account.

  4. You will be asked to choose an hosting address and if you want to use Git or Team Foundation Version Control. Select Git and click Continue.

  5. A new project called MyFirstProject will be automatically created.

Exercise 2: Create VSTS Git repository

VSTS gives us the option to use Git or TFVC as our project's repository. For this exercise we will use Git, and then clone the repository to our dev machine.

Note that if you acquired these lab materials via a git clone of the workshop repo then you should select a folder somewhere else on your dev machine. This will minimize conflicts between the two separate repositories.

  1. We will ignore the automatically created MyFirstProject. Starting at your TFVC account's landing page, click New Project.


  2. Enter a project name such as DevCamp, ensure Version control is set to Git and then click Create.


  3. Wait for the project to be created. This process may take up to 60 seconds. When finished you will be redirected to the project page

  4. Click Dashboards and explore your pre-built dashboard. Familiarize yourself with the variety of widgets available, and the customization options.


You have now created a project in VSTS with a Git repository. Next we'll clone the repository locally to your developer machine and upload code from our machine to VSTS.

Exercise 3: Add application to VSTS Git

  1. Click Code on the top toolbar to navigate to the Code screen. Then click the Generate Git Credentials button to set a user name, alias, and password.


  2. Next, select the Copy icon to copy the HTTPS URL for the repository.

  3. In a console window, navigate to a spot on your dev machine and execute a git clone


    Depending on your environment setup you may need to authenticate with VSTS.

  4. When we cloned our repository it was empty. Take the code that you have developed in the earlier labs (or the start folder bundled with this readme) and paste it into our new directory. This can be done via the command line, or with good old copy/paste in an Explorer or Finder window.


    Depending on how your environment is setup, there may be a hidden folder .git in your originating directory. Do not copy this folder into the destination directory linked to VSTS.

  5. Back in the console, execute a git status to ensure the files are picked up by git.

    git status


  6. Execute git add * to track the files, then a git commit -m "initial upload" to commit the files to the repository. Finally, execute git push origin master to push the files up to VSTS.

    git add *
    git commit -m "initial upload"
    git push origin master


    You might have to provide information before you can make your first commit. In this case execute these lines with your login data and try again:

    git config --global ""
    git config --global "Your name"
  7. In the browser, reload the Code page to see the uploaded code:


  8. Now, any changes you make to the local repository can be pushed up to VSTS. Other team members may also begin interacting with the code base via their own clones and pushes.

    Note that we did not include the node_modules or .vscode folders. These components are typically not added to source control, as they bloat the size of the repository. These files should have been excluded from your repository due to settings in the .gitignore file.

Exercise 4: Create a Continuous Integration pipeline

With application code now uploaded to VSTS, we can begin to create builds via a Build Definition. Navigate to the Build tab from the top navigation. We will use the hosted agent within VSTS to process our builds in this exercise.

  1. From the Build & Release tab, create a new Build Definition by clicking the New Definition button:


  2. There are prebuilt definitions for a variety of programming languages and application stacks. For this exercise select Empty and click Apply:


  3. Use the suggested name and select the Default from the Default agent queue drop-down.


  4. The build tasks are created for us as part of the template.

  5. On the Get sources step set the From value to your VSTS Project and the Repository to the repo that was earlier created.


  6. After the empty Build Definition is created, we need to create a series of Build Steps.

    • Verify NodeJS version installed on the build agent by echoing it to the console.
    • Restore all package dependencies with npm install.
    • Package the code assets into a deployable zip file.
    • Publish the zip file as a Publish Artifact that can be consumed by the VSTS Release System.

    Each of these steps will begin by clicking the Add Task button.

  7. Add a Build Step for Command Line, found under the filter for Utility. Click Add and then select the newly added task to configure it.


    • Change the name of the build step to Echo Node Version.
    • Change the value Tool to node and the value Argument to -v.


  8. Add a Build Step for npm, found under the filter for Package. Click Add and then select the newly added task to configure it.


    • Change the name of the build step to Install Dependencies.
    • Change the value Command to install.


    If you are using devDependencies in your package.json and want to control whether or not they are installed, then pass the --production flag in the Argument field.

  9. Add a Build Step for Archive, found under the filter for Utility. Click Add and then select the newly added task to configure it.


    In configuration boxes, we can use variables in addition to string literals.

    • Configure Root Folder to use the directory on the Build Agent that contains our sources files by inserting $(Build.SourcesDirectory).
    • For Archive file to create insert $(Build.SourcesDirectory)/archive/$(Build.BuildId).zip. This will dynamically name our zip file of code with the build number.
    • Uncheck the box for Prefix root folder name to archive paths to avoid an unnecessary nesting within the .zip file.

    You can define your own variables to use throughout the Build and Release pipelines by clicking Variables in the Build Definition's sub-navigation. Also see here for all pre-defined variables available.


  10. Finally, a Build Step for Publish Build Artifacts, found under the filter for Utility. Click Add and then select the newly added task to configure it. This step outputs a file(s) from our Build Definition as a special "artifact" that can be used in VSTS' Release Definitions.


    • Change the value Path to Publish to $(Build.SourcesDirectory)/archive/$(Build.BuildId).zip to target the zip file created in the previous Build Step.
    • Change the value Artifact Name to drop.
    • Change the value Artifact publish location to Visual Studio Team Services/TFS.


  11. Click Save & queue. Our saved Build Definition is ready to be processed by the Hosted Build Agent.



  12. Accept the defaults and click Queue. Your build will then be queued until the Hosted Build Agent can pick it up for processing. This typically takes less than 60 seconds to begin.

  13. Once your build completes, click each step on the left navigation bar and inspect the output.


  14. Once your build completes, click each step on the left navigation bar and inspect the output. For Echo Node Version we can see the agent's version in the right Logs pane.


  15. Let's inspect the output artifacts that were published. Click the Build XXX header in the left pane to view the build's landing page.


  16. Select Artifacts from the horizontal toolbar.

  17. A drop folder has been created containing the compiled output. Click Explore to see them.

  18. Expand the drop folder and view the build artifacts. Click Close when complete.

  19. Click Download next to the drop folder to save the build locally.

  20. Unzip to see the application files created by the build agent (including the restored node_modules folder). This artifact will be deployed to an Azure Web App in a later exercise.


We now have a Build Definition that will construct our NodeJS application and package it for deployment anytime code is checked into the repository, or a manual build is queued.

Exercise 5: Deploy code to an Azure Web App

In the ARM Template that was originally deployed, a web app was created as a development environment to hold a deployed NodeJS application. We will use this web app as a deployment target from VSTS. First, we need to prepare this web app for our application code.

  1. Visit the Azure Web App by browsing to the Azure Portal, opening the DevCamp Resource Group, and select the Azure Web App resource that begins with nodejsapp before the random string.


  2. Once the blade expands, select Browse from the top toolbar:


  3. A new browser tab will open with a splash screen visible. It will look similar to this image (it gets updated regularly with new information) and tell you that the app service has been created:


  4. We can deploy our code to this Azure Web App, however it was not configured with our AzureAD details. When trying to authenticate, AzureAD would refuse since it does not know about this domain.

    To fix this, return to the Application Registration Portal, login, and open your application settings.

    In the section for Platforms, click Add Url to add the URL of your Azure Web App from Step 1. Remember to append the /auth/openid/return route at the end, since that is the route that will process the return data from AzureAD. Ensure this address is using https.


    Make sure you click Save at the bottom of the screen to add the URL to your AzureAD app.

  5. Now that AzureAD is configured, we need to add our AzureAD related environment variables to the Azure Web App. Back in the nodejsapp... blade where you hit Browse earlier, open Application Settings from the left navigation.

    Find the App Settings section containing a table of settings. In the ARM Template we auto-generated the majority of these settings, however we need to add a few additional environment variables to match the .vscode/launch.json file that we have been using locally.

    • AAD_RETURN_URL should be set to the same URL that we just configured for our AzureAD application. Should be similar to Ensure this is using https.

    • AAD_CLIENT_ID should match the Application ID in the Application Registration Portal and similar to 2251bd08-10ff-4ca2-a6a2-ccbf2973c6b6.

    • AAD_CLIENT_SECRET should be the Application Secret generated in the apps portal, and be similar to JjrKfgDyo5peQ4xJa786e8z.


    After you have created the new settings, click Save.

  6. Now that we have a build being created and a website to deploy into, let's connect them. Back in our VSTS Build Definition, navigate to the Build & Release tab.

  7. Click on Releases.

  8. Click the + New Definition button to create a new release definition:


  9. Select Empty and click Apply.


  10. Click Add artifact, select the build definition you created as the Source (Build definition) and click Add. Now the artifacts the build definition created will be available in the new release definition.


  11. Switch to Tasks and click the + button.

    In the task catalog, find Azure App Service Deploy and click Add.


  12. Click on the task name Azure App Service Deploy to open the attributes for that task. VSTS will need a connection to the Azure subscription that you are deploying the application to.

  13. If the drop-down next to Azure subscription offers you your subscription, select it, authorize it and continue to select your nodejsapp... Azure Web app resource from the App Service name drop-down.

  14. If the drop-down next to Azure subscription does not offer you your subscription or the drop-down next to App Service name does not offer you your Azure Web app resource (give it a moment after selecting the subscription), click on Manage to open a new browser tab holding configuration options.


    1. In the new tab, select New Service Endpoint and from the drop-down choose Azure Resource Manager.


    1. The modal window should automatically determine your subscription information. Provide a name such as Azure, select OK, and a close the browser tab.


    1. If your subscription is not in the drop-down list, click the link at the bottom of the window, and the window format will change to allow you to enter connection information on your subscription:


    1. If you have not created a service principal for the subscription, you will have to follow the instructions to do so. This process will provide the information to enter in this dialog:

      1. Open this PowerShell script in your browser.
      2. Select all the content from the window and copy to the clipboard.
      3. Open a PowerShell ISE window.
      4. In the text window, paste the PowerShell script from the clipboard.


    1. Click the green arrow to run the PowerShell script.


    1. The PowerShell script will ask for your subscription name and a password. This password is for the service principal only, not the password for your subscription. So you can use whatever password you would like, just remember it.


    1. You will then be asked for your Azure login credentials. Enter your Azure username and password. The script will print out several values that you will need to enter into the Add Azure Resource Manager Service Endpoint window. Copy and paste these values from the PowerShell window:

      • Subscription ID
      • Subscription Name
      • Service Principal Client ID
      • Service Principal Key
      • Tenant ID

    Also, enter a user-friendly name to use when referring to this service endpoint connection.


    Click Verify connection, and ensure that the window indicates that the connection was verified. Then Click OK and Close.


    This pattern is used to connect to a variety of services beyond Azure such as Jenkins, Chef, and Docker.

  15. Back on the VSTS Build window, in the Build Step we started earlier, click the Refresh icon. The Azure connection that we setup should now appear. Select it.


    Next, for App Service Name click the Refresh icon, choose the name of the NodeJS Azure Web App. It may take a moment to populate.


  16. Save the Build Definition, accepting the default folder and supplying a comment if you'd like. Next, click Release and Create Release:


    In the following window, type a description for the release and click Create:


    You should see a message that your release has been created. Click on the link for Release-1.


    You will see the status for the release:


    When the release is complete, browse to the deployment website. You should see the same application you tested in the modern-apps lab:


    If you make changes to the application and git push back to the VSTS server, this will automatically trigger a build and deployment. Try to make a small change to the application and verify that the application is re-deployed to the test environment.


In this hands-on lab, you learned how to:

  • Create a Visual Studio Team Services online account that you used for version control of your code, automatic compiling and deploying of your web app.
  • Create a VSTS Git repository that you utilized to synchronize your source code on your machine and in the cloud.
  • Add your code to the VSTS Git repository.
  • Create a Continuous Integration pipeline that you used to automatically compile your application and create packages for deployment anytime code is checked into the repository.
  • Deploy a built application to an Azure Web App from VSTS and thus automating the final steps of your deployment process.

After completing this module, you can continue on to Module 5: ARM.

View instructions for Module 5 for NodeJS.

Copyright 2016 Microsoft Corporation. All rights reserved. Except where otherwise noted, these materials are licensed under the terms of the MIT License. You may use them according to the license as is most appropriate for your project. The terms of this license can be found at

You can’t perform that action at this time.