How to delete deployment in VRA 8 using Python(API)

Often there are situation where deployment will get stuck in progress or We lost control to manage the deployment using GUI. In those situation we can utilize the APIs and get the task done.

But for VRA8 taking the bearer token is bit tedious task as we need to obtain 2 different token then make it as bearer token. To make it easier I have created Python Module where you just need to provide the Admin credentials and perform the operation .

To start the Process we need to meet the pre-requisites which are explain in below steps.

No need to worry about if you are not from python background or do not know code, Just follow the below instruction and we are good .

  1. Please follow the detailed instruction Here python installation and required module before we use this module –Do not skip this step.
  2. Download the file from Above and unzip and copy the file by name VRA8 and paste the file in directory where python is installed
    general path in windows is : C:\Users\Administrator\AppData\Local\Programs\Python\Python39
  3. I am using Python 3.9 for example ,It will be different as per your version.
  4. Once the step 1-3 is completed , all we need to do is run the below commands.
from VRA8 import vraClass
as1 =vraClass(vrafqdn="", username="administrator", password="VMware123!")

as1.getDeployments() -By Default this will list the 10000 deployment , We need to get the deployment ID from the list.

As we see , I have total 22 deployment in my environment and Now I will trigger the delete deployment request for deployment name Test11 for that ID is -6130ead4-638f-4050-ae7d-9279ee51ffa8.


Here response 202 means API has been triggered to delete . Now if we do getDeployment() again we only see 21 entries.

There are some additional function also which are part of this python module
Like getBlueprint() & releaseBlueprint()

Here is the quick look of both of them

as1.releaseBlueprint(id="cf9641b4-0242-4555-abae-26d8b72f542d", version=11)

Happy Learning , Feel free to share your queries and feedback on this .

2 thoughts on “How to delete deployment in VRA 8 using Python(API)

  1. Pingback: How to remove machine from VRA which are stuck in provisioning status in VRA8 | VMwareCode

  2. I have implemented and it worked.
    But on event of CREATE_FAILED of deployment how to use in Extensibility or VRO Workflow to use this Python script


Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s