Recently I was tasked to create some kind of instant auto-removal of failed Aria Automation deployments for a given Cloud template.

This can be achieved through leveraging a custom day 2 operation using the Aria Automation Deployment API request controller. For this particular use-case we execute the deployment resource “delete” action.

The required REST call for this resource action is: POST /deployment/api/requests/{requestId}
The JSON body must be specified as follows: { “actionId”: “Deployment.Delete”}

To execute this action every time a deployment fails, we use an Extensibility subscription to be automatically triggered if the status of the deployment is “FAILED” and the event type equals “CREATE_DEPLOYMENT”.

In this example we will use Aria Orchestrator to create the custom action.

The actual implementation consits of the following steps:

  • Create the EBS Orchestrator workflow
  • Create the Extensibility subscription

Create the EBS Orchestrator workflow

We create a new workflow for the Extensibility subscription, e.g. name it “Delete Deployment“.
Create a new input parameter: inputProperties [type: Properties]
The workflow itself contains of the scriptable task with the following JavaScript code:

function deleteDeployment(deploymentId) {
    var bodyString = JSON.stringify({
        "actionId": "Deployment.Delete"
    });
    var vraHost = System.getModule("home.lab").getVraEndpoint();
    var restClient = vraHost.createRestClient();
    var request = restClient.createRequest("POST", "/deployment/api/deployments/" + deploymentId + "/requests", bodyString);
    var response = restClient.execute(request);
    return response;
}

var result = deleteDeployment(inputProperties.deploymentId);
if (result.statusCode >= 400)
	throw "The deletion of the deployment " 
        + inputProperties.deploymentId 
        + " failed with status " 
        + result.statusCode + ". " 
        + result.contentAsString;

To determine the Aria Automation endpoint in the Orchestrator environment, we use the Orchestrator action getVraHostVcoEndpoint. In this lab environment, we use the default onprem endpoint.

The action has no Input properties and a Return type of VRA:Host.

var vraHost;
for each (var vraHostFinder in VraHostManager.findHostsByType('vra-onprem')) {
    if (vraHostFinder.name === 'Default') {
        System.debug("Found default vRA host");
        vraHost = vraHostFinder;
        break;
    }        
}
if (vraHost == null)
    throw "vRA host not found";
return vraHost;

Create the Extensibility subscription

To trigger the workflow everytime a Aria Automation deployment fails, we create the following Extensibility subscription:

  • Name: Delete Failed vRA Deployment
  • Status: Enable subscription (yes)
  • Event Topic: Deployment completed
  • Condition: event.data.status == "FAILED" && event.date.eventType == "CREATE_DEPLOYMENT"
  • Action/workflow: Delete vRA Deployment
  • Blocking: Block execution of events in topic (yes)

Note with the above created trigger condition, the subscription will be run for every failed create deployment. To limit it to a given cloud template, we could use an additional “event.data.blueprintId” condition which specifies the corresponding Cloud template Id.