vRA 7.5/7.6 – Change / Set Deployment Name during Provisioning with EBS & vRO

The Problem

Since vRA 7.5 we have the option to change the Name & Description of our Deployment via the UI as shown below:


But what if we would like to Change a Deployment’s Name programatically? What if we would like to set it during provisioning to match our VM’s Name for example? Can we do that? The short answer: Yes! With an undocumented API call (at least at time of writing this article).

I’ve came across a couple of Use Cases in the past that would like to have this functionality. The only way that I found one could edit the Deployment Name was to do it via the UI or by setting the __deploymentName Custom Property on the Blueprint at request time. After numerous tests with ‘__deploymentName‘ and a lot of Google Magic, it did not seem possible to modify that Custom Property during Provisioning with EBS for example.

The Solution

The solution to this problem is to use an Undocumented API Call:

HEADERS: Accept : application/json | Content-Type : application/json | Authorization : Bearer <Your_Token>
URL: https://<your_vra_fqdn>/catalog-service/api/consumer/deployments/{id}
         "name":"NEW Name",
         "description":"NEW Description"

Luckily for us we can do REST API Calls to our vRA Appliance with vRO. You have a couple of possibilities in vRO for achieving this functionality:

  1. Using the REST Host functionality of vRO
  2. Using the vRA CafeHost functionality of vRO

In this Blog Post I’ll explain the 2nd Option. Hang on!

How to implement

vRO Work

  1. Create new Action called  ‘getDeploymentByResourceID
    INPUT: cafeHost – vCACCAFE:VCACHost | requestId – string

    //Declare Variables
    var requestService = cafeHost.createCatalogClient().getCatalogConsumerRequestService();   
    var deployment = null;   
        //Get the Resource(s) provisioned by specific Request ID
        var results = requestService.getResourcesProvisionedByRequest(requestId);   
        var resources = results.getContent();   
        //Find  the Deployment Resource based on the Request ID  
        for each (resource in resources){  
             if (resource.resourceTypeRef.getLabel() == "Deployment"){  
                deployment = resource;  
        System.log("Error: Could not find Deployment Resource for Request ID: "+requestId+" See error message: "+exception);  
    return deployment;
  2. Create new Action called ‘setDeploymentName
    INPUT: cafeHost – VCACCAFE:VCACHost | resourceId : string | newName : string

    //Create the REST Client based on the vRA CafeHost for the given Tenant
    restClient = cafeHost.createRestClient("com.vmware.csp.core.cafe.catalog.api");  
    //Creating new Properties object to put new Name and / or Description in
    var props = new Properties();  
    props.put("name", newName);        
    //props.put("description", "New Description generated during lifecycle with EBS via vRO");  
    //Perform PUT call
    var response = restClient.put("/consumer/deployments/" + resourceId, props); 
    //Process statusCode / Error Handling
    statusCode = response.getStatus();
    System.log("Status code: " + statusCode);
    if (statusCode >= 400) {
    	throw new Error ("Error setting New Deployment Name: " + response.contentAsString);
    }else  {
    	var updatedName = response.getProperty("name");
    	System.log("Name successfully changed. See JSON Response for NAME property: "+updatedName);
  3.  Create a Workflow that will be triggered by Event Broker Subscription during the REQUESTED-POST phase for example. Named ‘Machine Requested – POST – Change Deployment Name
    WORKFLOW INPUT: payload – Properties
    ATTRIBUTES: cafeHost – VCACCAFE:VCACHost (SET THIS STATICALLY OR DYNAMICALLY WITH CODE) | cafeRequestID : string | vmName : string
  4. vRO Workflow:
    SCRIPTABLE TASK 1: Set Vars & Log
    OUTPUT: vmName (attr) & cafeRequestID (attr)

    //Logging the Payload
    var machine = payload.get("machine");
    var vmProperties = machine.get("properties");
    if(vmProperties != null){
    .forEach(function(key) {
    System.log(key + ": " + vmProperties.get(key));
    //Setting the Variables
    cafeRequestID = vmProperties.get("__Cafe.Root.Request.Id");
    vmName = machine.get("name");
    if (! cafeRequestID) {
    throw new Error ("Cannot find Cafe Root Request ID from the Catalog Request!");
    if (! vmName) {
    throw new Error ("Cannot find VM Name from the Catalog Request!");
    System.log("Root Cafe Request ID from Catalog Request: "+cafeRequestID);
    System.log("VM Name from Catalog Request: "+vmName);
  5. vRO Workflow: SCRIPTABLE TASK 2: Update Deployment Name
    INPUTcafeHost (attr) & vmName (attr) & cafeRequestID (attr)

    System.log("Setting Deployment Name for Deployment with Request ID: "+cafeRequestID); 
    var deployment = System.getModule("<Path_To_Your_Action>").getDeploymentByResourceID(cafeHost, cafeRequestID);
    if (deployment){ 
          //Get Resource ID from Deployment
          var resourceId = deployment.id; 
         //Retrieve current Deployment Name + set new one 
         var currentDeploymentName = deployment.name; 
         var newDeploymentName = vmName; 
         System.log("Current Deployment Name is: " + currentDeploymentName); 
         System.log("New Deployment Name is: " + newDeploymentName); 
             System.getModule("<Path_To_Your_Action").setDeploymentName(cafeHost, resourceId, newDeploymentName); 
             System.log("Failed to update deployment name with error: " + e); 
  6. vRO Overview Result:

vRA Work

  1. Now modify your existing Event Broker Subscription setup to include your newly created vRO workflow or set up a new one!
  2. Example setup below:
    EVENT TOPIC: Machine Provisioning
    Data > Lifecycle State > State Phase Equals POST
    Data > Lifecycle State > Life Cycle State Name Equals VMPSMasterWorkflow32.Requested
    vRO WORKFLOW: Machine Requested – POST – Change Deployment Name
  3. vRA Result Overview:


Now when you provision a new machine, the Deployment Name will be changed to the VM name (or something else you’ve specified). See screenshots below:

Hopefully this could be of assistance for you.
I did not test it out on vRA versions lower than 7.5. If you have tested it, feel free to share!

If there are any questions / comments, don’t hesitate to let us know.

Have a nice day!


One thought on “vRA 7.5/7.6 – Change / Set Deployment Name during Provisioning with EBS & vRO

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s