• Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy
Cybersylum

Cybersylum

  • Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy

Using Aria Automation APIs with PowerShell

byArron King 07.15.2023 Aria Automation

I needed to update a few bits of information for the networks in my on-prem Aria Automation deployment.  It would have been pretty easy to update via the GUI.  I thought this was a great opportunity to start learning about using Aria Automation APIs with PowerShell.

I thought I would share what I found to hopefully help someone new to APIs. This could also be useful if someone needed to make these changes in bulk.    Let’s take a look!

Figuring things out

I started by reviewing the Aria Automation API Documentation (also known as the Swagger UI) built into each vRA install (in your environment go to https://your-vra-fqdn.com/automation-us/api/docs).

The Swagger UI will help describe how to use the APIs and even provides an interface to test them out.

Under the Infrastructure As A Service category, I found APIs for Cloud Accounts.

swagger documentation on APIs for Cloud Accounts

 

 

 

 

Confusing?
Most VMware APIs tend to mirror the organizational constructs you see in the product.  In this case, login to vRA Cloud Assembly and go to Infrastructure -> Connections -> Cloud Assembly.   This contains the Cloud Accounts defined in Aria Automation. You can navigate to the section of the same name in the Swagger UI (Infrastructure as a Service).  No doubt it will take some experimentation and research but this can help point you in the right direction

Once the proper API call is known, you can turn your attention to how to make the call and get data back.  I like using Postman for modeling and testing:

  • It gives me the ability to save collections of API calls so I can re-use them
  • Using the editor I can determine the correct format for the API call and input
  • The output window makes it easy to understand how the data returned will be formatted

Using the Cloud Accounts API call details from Swagger, I was able to construct the call in Postman and see what data was returned.  The top half describes the API call and the bottom half shows the return after the API call was sent.

Postman API Prototyping for Cloud Accounts

 

 

 

 

 

 

 

 

Having this info helps me understand what data structures are returned from the API call. I can now start to craft some PowerShell around it

Writing PowerShell Code to interact with APIs

PowerShell does include cmdlets to interact with APIs – check out invoke-rest method.   These work but can be complicated.  Using the Cloud Account use case and the native PowerShell invoke-rest method:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Grab the bearer token for use with invoke-restmethod (which is needed for queries with more than 100 results)
$APItoken= $vRA.token | ConvertTo-SecureString -AsPlainText -Force
 
$Body = @{
    '$top' = $QueryLimit
}
$APIparams = @{
    Method = "GET"
    Uri = "https://$vRAServer/iaas/api/cloud-accounts"
    Authentication = "Bearer"
    Token = $APItoken
    Body = $Body
}
 
try{
    $CloudAccounts = (Invoke-RestMethod @APIparams -SkipCertificateCheck).Content
} catch {
    Write-Host $("    Unable to get Cloud Accounts from Aria Automation")
    Write-Host $Error
    Write-Host $Error[0].Exception.GetType().FullName
}
 
Write-Host "Cloud Accounts found - " $CloudAccounts.Count

 

In the case of Aria Automation, there is a project called PowervRA (project page / documentation).  The cmdlets provided by PowervRA can make it much easier to automate Aria Operation from PowerShell. It vastly simplifies the process of authenticating and making the necessary API calls.

Using our Cloud Account example from earlier, I can connect to Aria Automation, and return all configured Cloud Accounts in just a couple of lines of traditional PowerShell code

Using PowervRA to return all Cloud Account Names in 3 lines of PowerShell

 

 

 

 

Aria Automation or vRA / vRealize Automation. Which is it?
If you are somewhat new to Aria Automation, you may not be familiar with vRealize Automation or vRA. This was the name the product originally had before it was changed shortly after 8.x was released. You can read more of the history here.

Shoutout to the PowervRA Team

I wanted to take a moment and give the maintainers of the PowervRA project some thanks.  This group of people volunteer their time to work on code that many use and benefit from. This is a community project and not sponsored by VMware or any other company.   This is difficult work that is probably not the job paying their bills. This project started in earlier versions of the product and had to pivot hard when the product went through a major roadmap shift that had drastic impact to its APIs.

I wouldn’t have had the courage to try much of my recent work had it not been for their efforts.  If you look at my recent projects, you will notice I have been writing a lot on using PowerShell to automate Aria Automation.    My understanding and code have evolved over the past few months. There are two things I would share:

  • Be sure to read the correct version of PowervRA  and its documentation (project page / documentation).   It was not clear to me initially and I wasted some time.  you will want to look at  versions past 4.0 as those have been updated to work with the new APIs in Aria Automation 8.x.
  • Don’t be afraid to use what works.  I use a bit of everything in my code  – from native invoke-restmethod, to PowervRA’s cmdlet to connect to vRA (connect-vraserver) to the PowervRA invoke-vrarestmethod so I can access APIs that do not yet have a cmdlet.

 

 

 

 

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn

vToobelt - July 2023

vToolbelt - September 2023

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Disclaimer

The content and opinions on this site belong to me - not my employer.

You are welcome to use any ideas or code from this site. You have the responsiblity to test these before using in a production environment.

Upcoming Events

  • Wed
    22
    Oct
    2025

    Cincinnati VMware VMUG UserCON

    Save The Date!

    The VMware VMUG UserCON returns to Cincinnati in October 2025

Categories

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10

Archives

Category

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10
Proudly powered by WordPress | Theme: Showme by NEThemes.
 

Loading Comments...