vRealize Automation REST API – Deploy 3 Tier App with NSX networks On-Demand on VCF on VxRail
In this blog, I will cover vRealize Automation operations using REST API via Postman. The main goal of this blog is to provide handy example for vRA operation using API’s.
The vRealize Automation REST API provides consumer, administrator, and provider-level access to the service catalog with the same services that support the vRealize Automation console user interface.
You can perform vRealize Automation functions programmatically by using REST API service calls.
The vRealize Automation REST API offers the multiple services and functions. For detailed offering, please refer VMware Programming Guide for vRA.
REST Client Applications
Any client application that can send HTTPS requests is an appropriate tool for developing REST applications with the vRealize Automation API. The following open-source applications are commonly used:
- cURL
- Postman application
Let us go through some of vRA operations using Postman client. I presume you have already installed or have access to Postman client or plugin whichever suites best for your environment.
We will start with creating some Environment Variables for vRA interface. The Environment variables will be used in sending your requests to API endpoints that you want to reach and perform some actions.
Variables allow you to store and reuse values in your requests and scripts. By storing a value in a variable, you can reference it throughout your collections, environments, and requests—and if you need to update the value, you only have to change it in one place. Using variables increases your ability to work efficiently and minimizes the likelihood of error.
Click the Environment quick look (eye button) in the top right of Postman and add necessary variables as below.
Define Postman environments
Here you will see, I have added vRA information as part of the necessary variables.
- va-fqdn: Hostname/IP for the virtual appliance (or load balancer)
- username: A tenant user with the format of username@domain
- password: The password for the above username
- tenant: The tenant for which the APIs are executed.
- page: Default page when more than one page is returned in a GET call
- limit: Page limit, It limits the number of objects returned in per page
- system-user: A system level user e.g. [email protected]
- system-password: The password for system level user
- system-tenant: The system tenant e.g. vsphere.local
Authentication
Most of the vRealize Automation API calls are authorized by relevant roles. Before executing any API, make sure you login with relevant user authorized to perform the operation. Each of these use cases should have a login method. Send a login call after setting postman environment and it will retrieve the token and will set in environment variable in Postman. There is no need to copy the token over to next API method authorization header as all the APIs headers are set. Use above mentioned environment variable and modify according to your setup.
Login
Use any of the Login calls to authenticate.
When login is successful the environment variable {{token}} can be set.
Once the token is acquired, you can make subsequent calls as below. The {{token}} can be added into as an variable or can be passed to the request.
Here we will use the token to deploy 3-Tier Application with NSX on-demand network blueprint on vRA.
Make sure you have a working Blueprint on vRA and you have the blueprint ID available in hand to be used with Postman API.
Now, login to vRA portal and verify if deployment is started.
Cool, shortly you will see the 3-Tier application is deployed on On-Demand NSX networks.
Hope you enjoyed this post, I’d be very grateful if you’d help sharing it on Social Media. Thank you!