Retrieve Blueprint or Virtual Machine Custom Properties using the vRealize Automation API

Written by Sam McGeown
Published on 2/2/2018 - Read in about 2 min (308 words)

Just a quick post today, as I was working with a customer recently and we were trying to retrieve the Custom Properties assigned to a vRealize Automation 7.3 deployed Virtual Machine, similar to the one in the image below. It’s not as intuitive as you’d like it to be because of the split between IaaS APIs and Cafe APIs. Below you can see I’ve deployed a simple CentOS blueprint with a custom property at the Blueprint level (called “BlueprintLevel” with a value of “CustomProperty”) and a custom property at the VM level (called “CustomProperty” and a value of “Test123”).

vRA Blueprint Custom Property vRA VM Custom Property

Authenticating with the vRA API

The first step when working with the vRA API is to get the bearer token by sending the username, password and tenant to the token service:

https://{{vra-fqdn}}/identity/api/tokens

vRA API Get Bearer Token

I have stored the value of the bearer token in a Postman variable {{token}}.

Finding the Blueprint’s Custom Property

It’s an odd quirk with the vRA API that even through you return the Catalog Resource with the resources API, you can’t see the property directly. There is a little trick to finding it though, by retrieving the form for the resource.

Query the resource and filter by the resource by the deployment name - “CentOS6-ExternalNetwork-58506054”

https://{{vra-fqdn}}/catalog-service/api/consumer/resources?$filter=name eq ‘CentOS6-ExternalNetwork-58506054’

vRA API - Find Resource ID

Grab the resource ID and query the form:

https://{{vra-fqdn}}/catalog-service/api/consumer/resources/d4692cad-7fd3-4242-8472-6ed4359141bf/form

vRA API Blueprint Level Custom Property

There is an id assigned to the custom property (provider-PROP_BlueprintLevel), which you can use to find the value in the “values” array below. Not ideal, but workable.

Finding the Virtual Machine’s Custom Property

Next we can query the resource and filter by the resource by the Virtual Machine name - “lab00143”

https://{{vra-fqdn}}/catalog-service/api/consumer/resources?$filter=name eq ’lab00143'

Get vRA Resource by Name

Find and grab the providerBinding.bindingId, and query the IaaS server (using NTLM authentication) to retrieve the VirtualMachineProperties.

https://{{vra-iaas}}/repository/Data/ManagementModelEntities.svc/VirtualMachines(guid'76e88125-8c81-4de0-82d9-f3e6f41f9531′)/VirtualMachineProperties

vra-custom-property

Hope this quick snip helps you with retrieving the properties from a blueprint or an IaaS virtual machine!

Share this post