VMware Horizon Cloud Service Next-Gen – The Automation Series – Chapter 8 – Site/Edge Mapping

This blog post is part of the VMware Horizon Cloud Service Next-Gen – The Automation Series, a series of blog posts that describes the possibilities and use of the VMware Horizon Cloud Service Next-Gen APIs.

In this chapter we will add and delete a site/edge mapping configuration. We will use PowerShell to execute the requests. Since Azure is the only provider type supported at the time of writing this chapter, that’s the one we currently focusing on.

The original VMware documentation for site/edge mapping operations can be found here.

Create

We will start by creating an site/edge mapping configuration. For this we will use the following information:

HTTP Method PUT
URI https://cloud.vmwarehorizon.com/portal/v2/sites/

{siteId}/edge/{edgeId}

Content-Type application/json Header
Authorization Bearer <Access token> Header
siteId The id of the site URI
edgeId The id of the edge URI

With this information we will now construct the lines of code in PowerShell to add the site/edge mapping configuration.

(1) We create the access token from the API token using the New-HCSAccessToken function we described in chapter 2. We put this value in the $AccessToken variable, which we will use in the following step.

(2) We then construct the $Header array, where we specify the expected Content-Type to be received by the URI, which is application/json. And we specify the type of authorization using the Bearer type with the access token from the variable $AccessToken.

(3) We execute the command to add the site/edge mapping configuration (3). Once executed, the output with what has been configured will be displayed.

Get

There is no specific API for getting the configured site/edge mapping configurations. You can use the API for getting the site config(s) instead. This will display the edges that are linked to the site.

Delete

To delete a site/edge mapping configuration, we will use the following information:

HTTP Method DELETE
URI https://cloud.vmwarehorizon.com/portal/v2/sites/

{siteId}/edge/{edgeId}

Content-Type application/json Header
Authorization Bearer <Access token> Header
edgeId The id of the edge URI

(1) We create the access token from the API token again using the New-HCSAccessToken function, and put this value in the $AccessToken variable, which we will use in the following step.

(2) We construct the $Header array, where we specify the expected Content-Type to be received by the URI, which is application/json. And we specify the type of authorization using the Bearer type with the access token from the variable $AccessToken.

(3) We execute the command to delete the site/edge mapping configuration.

PowerShell Functions Examples

The scripts below serve as examples. You may change the scripts to your own needs or standards, like error handling, securing password strings and things like that.

I hope this chapter was informative and that you enjoyed reading.

Next up is Unified Access Gateway(s).

You may also like...