Provision and manage virtual machines in VMware

Last Update: 6/28/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions: XAML Build, Release

Also check out the new release definition editor.

This example shows how you can integrate VMware vCenter Server with Release Management in Visual Studio Team Services or Team Foundation Server. You can provision and manage virtual machines in vCenter and then deploy your apps to them.

Prepare

You will need a minimum of two machines - a target server or virtual machine to deploy to, and an agent machine that drives the deployment. You may have multiple target servers depending on how many nodes you want to deploy to. However, you only need one agent machine to drive the deployment.

  1. The extension uses the VMware vSphere Management SDK to call VMware API functions that access vSphere web services. To install and configure the SDK on the agent machine:
  • Download and install the latest version of the Java Runtime Environment from this location.

  • Go to this location and sign in with your existing credentials or register with the website. Then download the vSphere 6.0 Management SDK.

  • Create a directory for the vSphere Management SDK such as C:\vSphereSDK. Do not include spaces in the directory names to avoid issues with some of the batch and script files included in the SDK.

  • Unpack the vSphere Management SDK into the new folder you just created.

  • Add the full path and name of the precompiled VMware Java SDK file vim25.jar to the machine's CLASSPATH environment variable. If you used the path and name C:\vSphereSDK for the SDK files, as shown above, the full path will be:
    C:\vSphereSDK\SDK\vsphere-ws\java\JAXWS\lib\vim25.jar

  1. Install an agent on the agent machine:

  2. Install the VMware extension from Visual Studio Marketplace into your server or account.

    • If you are using Visual Studio Team Services, install the extension from this location in Visual Studio Marketplace.
    • If you are using Team Foundation Server, download the extension from this location in Visual Studio Marketplace, upload it to your Team Foundation Server, and install it.

  3. Follow these steps to create a vCenter Server Service endpoint in your team project:

    • Open your Team Services or TFS team project in your web browser. Choose the Settings icon in the menu bar and select Services.

    • In the Services tab, choose New Service Endpoint, and select VMware vCenter Server.

    • In the Add new VMware vCenter Server Connection dialog, enter the values required to connect to the vCenter Server:

      • Connection Name: Enter a user-friendly name for the service endpoint such as Fabrikam vCenter.
      • vCenter Server URL: Enter the URL of the vCenter server, in the form https://machine.domain.com/. Note that only HTTPS connections are supported.
      • Username and Password: Enter the credentials required to connect to the vCenter Server. Username formats such as username, domain\username, machine-name\username, and .\username are supported. UPN formats such as username@domain.com and built-in system accounts such as NT Authority\System are not supported.

  4. Choose OK to save the settings and create the connection.

Deploy

  1. Open the Releases tab of the Build & Release hub and choose the "+" icon to create a new release definition.

  2. In the Create release definition dialog, select the Empty template and choose Next.

  3. In the next page, select Choose Later and then choose Create. This creates a new release definition with one default environment and no linked artifacts.

  4. Choose + Add tasks and add a VMware Resource Deployment task from the Deploy section of the Task catalog dialog to the environment.

  5. To configure the VMware Resource Deployment task to take snapshot of virtual machines, or to revert or delete them, use these settings:

    VMWare Resource Deployment VMWare Resource Deployment - Connect to a VMware vCenter Server, easily provision VMs, and perform actions on them.

    • VMware Service Connection: Select the VMware vCenter Server connection you created earlier.

    • Action: Select one of the actions: Take Snapshot of Virtual Machines, Revert Snapshot of Virtual Machines, or Delete Snapshot of Virtual Machines.

    • Virtual Machine Names: Enter the names of one or more virtual machines. Separate multiple names with a comma; for example, VM1,VM2,VM3

    • Datacenter: Enter the name of the datacenter where the virtual machines will be created.

    • Snapshot Name: Enter the name of the snapshot. This snapshot must exist if you use the revert or delete action.

    • Host Name: Depending on the option you selected for the compute resource type, enter the name of the host, cluster, or resource pool.

    • Datastore: Enter the name of the datastore that will hold the virtual machines' configuration and disk files.

    • Description: Optional. Enter a description for the Take Snapshot of Virtual Machines action, such as $(Build.DefinitionName).$(Build.BuildNumber). This can be used to track the execution of the build or release that created the snapshot.

    • Skip Certificate Authority Check: If the vCenter Server's certificate is self-signed, select this option to skip the validation of the certificate by a trusted certificate authority.

    To verify if a self-signed certificate is installed on the vCenter Server, open the VMware vSphere Web Client in your browser and check for a certificate error page. The vSphere Web Client URL will be of the form https://machine.domain/vsphere-client/. Good practice guidance for vCenter Server certificates can be found in the VMWare Knowledge Base (article 2057223).

  6. To configure the VMware Resource Deployment task to provision a new virtual machine from a template, use these settings:

    VMWare Resource Deployment VMWare Resource Deployment - Connect to a VMware vCenter Server, easily provision VMs, and perform actions on them.

    • VMware Service Connection: Select the VMware vCenter Server connection you created earlier.

    • Action: Deploy Virtual Machines using Template

    • Template: The name of the template that will be used to create the virtual machines. The template must exist in the location you enter for the Datacenter parameter.

    • Virtual Machine Names: Enter the names of one or more virtual machines. Separate multiple names with a comma; for example, VM1,VM2,VM3

    • Datacenter: Enter the name of the datacenter where the virtual machines will be created.

    • Compute Resource Type: Select the type of hosting for the virtual machines: VMware ESXi Host, Cluster, or Resource Pool

    • Host Name: Depending on the option you selected for the compute resource type, enter the name of the host, cluster, or resource pool.

    • Datastore: Enter the name of the datastore that will hold the virtual machines' configuration and disk files.

    • Description: Optional. Enter a description to identify the deployment.

    • Skip Certificate Authority Check: If the vCenter Server's certificate is self-signed, select this option to skip the validation of the certificate by a trusted certificate authority. See the note for the previous step to check for the presence of a self-signed certificate.

  7. You can now add other tasks to the environment, such as PowerShell on Target Machines, and then deploy to the newly provisioned machines.

    In the future we plan for the VMware Resource Deployment task to provide an output variable that you set in the task and then use as input to subsequent tasks. Until then, if you want to run additional tasks, you'll need to specify the fully-qualified domain names of the virtual machines that are provisioned in VMware.

  8. Type a name for the new release definition and save it.

  9. Create a new release from the release definition and deploy it to the environment.

Q&A

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.

Help and support