Create an empty vApp in vCloud Director

Sometimes you just need to create a new vApp with no contents at all – maybe for testing, or maybe you want to populate it with VMs built ‘from scratch’ rather than cloned from templates. This is easy to do in the vCloud Director web UI – you just skip the addition of any VM templates or new VMs and can easily create empty vApps, but how about programatically?

The VMware documentation is remarkably slim in this regard – all the documented methods I could find for vApp creation require either cloning from existing vApp templates, from existing VMs or from uploaded OVF files.

So how do we create a brand-new empty vApp? Turns out it’s pretty simple – once you discover the ‘composeVApp’ method on an Organization VDC supports creation of empty vApps.

If using the REST API we can simply create an XML body document of type ‘composeVAppParams’ and submit it against the OrgVDC’s /action/composeVapp link.

An example XML document body could be:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Description>My vApp Description</Description>

We then ‘POST’ this document body to the link: ‘https://<Cloud Server DNS name or IP address>>/api/vdc/<ID of our VDC>/action/composeVApp’ not forgetting to add a header of ‘Content-Type: application/vnd.vmware.vcloud.composeVAppParams+xml’ to the POST request.

If we want to accomplish the same thing using PowerShell / PowerCLI it’s easy too (once connected to our cloud using Connect-CIServer):

$vapp = New-Object VMware.VimAutomation.Cloud.Views.ComposeVAppParams
$vapp.Name = “MyEmptyVapp”
$vapp.Description = “My vApp Description”
$myorgvdc = Get-OrgVdc -Name ‘My OrgVDC Name’

No idea if this is ‘officially’ supported or not – so use at your own risk and be aware that the implementation could change in a future release and break this (although I’d be surprised as this is almost certainly the action that the vCD web UI is submitting ‘behind the scenes’ when you manually create an empty vApp).


Tagged , , , , , . Bookmark the permalink.

4 Responses to Create an empty vApp in vCloud Director

  1. Deb says:

    Is there a way to add a VM to an existing vApp. If yes could you please share how the xml body should be. I have been trying to find out and nothing is working for me.

    • Jon Waite says:

      Hi Deb, there are a couple of ways to do this that I know of via the API. If the VM to be added is available in a catalog vAppTemplate then you can use the recomposeVApp request (against the VDC object) to deploy into a new vApp (see on page 114 ‘Recompose a vApp to Add, Remove or Reconfigure Virtual Machines’. The other method is a bit trickier (but much more flexible) and allows you to create a new VM from scratch by submitting an OVF specification for the new VM to the vApp with an instantiateOvf request (page 99 in the same document). These links refer to the vCD 8.20 documentation set, but will be similar in earlier/later versions too.

      I’ve considered writing a post on creation of VMs from PowerCLI/PowerShell without relying on cloning vApp Templates so let me know if you’d find this useful.

      Regards, Jon.

      • Matthew says:

        I would appreciate if you could post how to create a VM from scratch by submitting an ovf specification, that would be great (for 8.20). If you are still around to do this!

  2. Adrian says:

    Hi Jon, just a quick note to say thank you for this. It worked just fine using the API (after a couple of false starts because I can’t read properly). Much appreciated! Adrian

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 4 =