How to create a resource pool in a hypervisor in Citrix Virtual Apps and Desktops
Use REST APIs to create a new resource pool in an existing hypervisor within your Citrix Virtual Apps and Desktops site.
Follow the prerequisites and examples to get started with this API.
You can make API requests using the PowerShell code, C# code, Python, or any tool that supports invoking the REST API.
Prerequisites to create a resource pool in a hypervisor
- Read the Learning journey for Citrix Virtual Apps and Desktops APIs section to ensure that you have the
bearer token
. - Get
siteid
from How to get site id API. - Get
nameOrId
of the hypervisor from How to get all hypervisors API. - Make sure you have a connection in
hosting
. - Make sure you have
Virtualnetwork
andSubnets
in your cloud service. - Invoke the API described in this document from a client host or from the API exploration tab to create a new resource pool on an existing hypervisor.
Create a new resource pool on a hypervisor using any REST API tool
Learn from the following example to create a new resource pool on an existing hypervisor within your Citrix Virtual Apps and Desktops site using any REST API tool.
Request
POST https://[DdcServerAddress]/cvad/manage/hypervisors/{nameOrId}/resourcePools HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
Citrix-InstanceId: 22ded57c-0306-47e4-b6e8-fed6252759e1
{
"ConnectionType": "AzureRM",
"Name": "CVAD_APIs_Resource_Pool_01",
"Region": "East US.region",
"VirtualNetwork": "East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"Subnets": [
"East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network"
]
}
<!--NeedCopy-->
Response
HTTP/1.1 201 Created
citrix-transactionid: 6c38078b...
content-Length: 767
content-Type: application/json; charset=utf-8
date: "Wed, 16 Sep 2020 09:50:04 GMT"
{
"Region": {
"RelativePath": "East US.region",
"FullRelativePath": "hypervisors/19ad12b0.../allResources?path=East US.region",
"ResourceType": "Unknown",
"Id": "eastus",
"Name": "East US",
"XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN\\East US.region"
},
"VirtualNetwork": {
"RelativePath": "virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"FullRelativePath": "hypervisors/19ad12b0.../resourcePools/8f8b0e47.../resources?path=virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"ResourceType": "VirtualPrivateCloud",
"ResourceContainer": {
"RelativePath": "East US.region",
"FullRelativePath": "hypervisors/19ad12b0.../allResources?path=East US.region",
"ResourceType": "Unknown",
"Id": "eastus",
"Name": "East US",
"XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN\\East US.region"
},
"ResourcePoolXDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud",
"Id": "studio-develop/studio-develop-vnet",
"Name": "studio-develop-vnet",
"XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN\\East US.region\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud"
},
"Subnets": [
{
"RelativePath": "virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network",
"FullRelativePath": "hypervisors/19ad12b0.../resourcePools/8f8b0e47.../resources?path=virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network",
"ResourceType": "Network",
"ResourceContainer": {
"RelativePath": "virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"FullRelativePath": "hypervisors/19ad12b0.../resourcePools/8f8b0e47.../resources?path=virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"ResourceType": "VirtualPrivateCloud",
"Id": "studio-develop/studio-develop-vnet",
"Name": "studio-develop-vnet",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud"
},
"ResourcePoolXDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud\\default.network",
"Id": "studio-develop/studio-develop-vnet/default",
"Name": "default",
"XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN\\East US.region\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud\\default.network"
}
],
"GpuTypes": [],
"Scopes": [
{
"Id": "00000000...",
"Uid": null,
"Name": "All",
"Description": null,
"IsBuiltIn": true,
"IsAllScope": true,
"IsTenantScope": false,
"TenantId": null,
"TenantName": null
}
],
"ConnectionType": "AzureRM",
"UsesExplicitStorage": false,
"HypervisorConnection": {
"Id": "19ad12b0...",
"Uid": 4,
"Name": "CVAD_APIs_CONN"
},
"DefaultNetwork": {
"RelativePath": "virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network",
"FullRelativePath": "hypervisors/19ad12b0.../resourcePools/8f8b0e47.../resources?path=virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network",
"ResourceType": "Network",
"ResourceContainer": {
"RelativePath": "",
"FullRelativePath": "hypervisors/19ad12b0.../resourcePools/8f8b0e47...",
"ResourceType": "Unknown",
"Id": "8f8b0e47...",
"Name": "CVAD_APIs_Resource_Pool_01",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01"
},
"ResourcePoolXDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud\\default.network",
"Id": "studio-develop/studio-develop-vnet/default",
"Name": "default",
"XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN\\East US.region\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud\\default.network"
},
"VMTaggingEnabled": true,
"Id": "8f8b0e47...",
"Name": "CVAD_APIs_Resource_Pool_01",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool_01"
}
<!--NeedCopy-->
Create a new resource pool on a hypervisor using PowerShell
Learn from the following example to create a new resource pool on an existing hypervisor within your Citrix Virtual Apps and Desktops site using any PowerShell code.
function CreateResourcePool {
param (
[Parameter(Mandatory=$true)]
[string] $customerid,
[Parameter(Mandatory=$true)]
[string] $siteid,
[Parameter(Mandatory=$true)]
[string] $nameOrId,
[Parameter(Mandatory=$true)]
[string] $bearerToken,
[Parameter(Mandatory=$true)]
[string] $body
)
$requestUri = [string]::Format("https://[DdcServerAddress]/cvad/manage/hypervisors/{0}/resourcePools", $nameOrId)
$headers = @{
"Accept" = "application/json";
"Content-Type"="application/json";
"Authorization" = "CWSAuth Bearer=$bearerToken";
"Citrix-CustomerId" = $customerid;
"Citrix-InstanceId" = $siteid;
}
$response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body
return $response
}
$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$nameOrId = "56f1cbf3-1cc6-40cd-9c82-c95633ba88bb"
$bearerToken = "ey1.."
$body = @"
{
"ConnectionType": "AzureRM",
"Name": "CVAD_APIs_Resource_Pool_01",
"Region": "East US.region",
"VirtualNetwork": "East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"Subnets": [
"East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network"
]
}
"@
$response = CreateResourcePool $customerid $siteid $nameOrId $bearerToken $body
<!--NeedCopy-->
Create a new resource pool on a hypervisor using C# code
Learn from the following example to create a new resource pool on an existing hypervisor within your Citrix Virtual Apps and Desktops site using C# code.
public static async Task<string> CreateResourcePool(
string customerid,
string siteid,
string nameOrId,
string bearerToken,
CreateHypervisorResourcePoolRequestModel model)
{
var requestUri = string.Format("https://[DdcServerAddress]/cvad/manage/hypervisors/{0}/resourcePools", nameOrId);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerid);
client.DefaultRequestHeaders.Add("Citrix-InstanceId", siteid);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);
var jsonBody = JsonConvert.SerializeObject(model, new JsonSerializerSettings
{
Converters = new JsonConverter[] { new StringEnumConverter() }
});
var response = await client.PostAsync(requestUri, new StringContent(jsonBody, Encoding.UTF8, "application/json"));
if (response != null)
{
var content = await response.Content.ReadAsStringAsync();
return content;
}
return null;
}
}
<!--NeedCopy-->
Create a new resource pool on a hypervisor using Python
Learn from the following example to create a new resource pool on an existing hypervisor within your Citrix Virtual Apps and Desktops site using Python.
import requests
def create_resource_pool(bearerToken, customerid, siteid, nameOrId):
request_uri = "https://[DdcServerAddress]/cvad/manage/hypervisors/{0}/resourcePools".format(nameOrId)
headers = {
'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
'Citrix-CustomerId': customerid,
'Citrix-InstanceId': siteid,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
payload = json.dumps({
"ConnectionType": "AzureRM",
"Name": "CVAD_APIs_Resource_Pool_01",
"Region": "East US.region",
"VirtualNetwork": "East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud",
"Subnets": [
"East US.region/virtualprivatecloud.folder/studio-develop.resourcegroup/studio-develop-vnet.virtualprivatecloud/default.network"
]
})
response = requests.post(request_uri, headers = headers, verify = False, data = payload)
return response.json()
<!--NeedCopy-->