Citrix DaaS REST APIs

How to create a hypervisor in Citrix DaaS

Use REST APIs to create a hypervisor, plus an optional resource pool on the hypervisor within your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) 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 hypervisor in Citrix DaaS

  • Read the Get started with Citrix Cloud APIs section to ensure that you have the bearer token.
  • Get siteid from How to get site id API.
  • Make sure you have cloud service provider such as Citrix Hypervisor, Microsoft Azure, Amazon EC2, Google Cloud Platform, and VMware vSphere.
  • Create domain service in your cloud service provider, and make sure that Citrix Connector has been installed in your domain service.
  • Invoke the API described in this document from a client host or from the API exploration tab to create a hypervisor, and optionally a resource pool on the hypervisor.

Create a hypervisor in your site using any REST API tool

Learn from the following example to create a hypervisor, plus an optional resource pool on the hypervisor within your Citrix DaaS site using any REST API tool.

Request

POST https://api.cloud.com/cvad/manage/hypervisors 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

{
    "ConnectionDetails": {
        "Name": "CVAD_APIs_CONN",
        "ConnectionType": "AzureRM",
        "ApplicationId": "aa8f1fd6...",
        "ApplicationSecret": "YQ?u...",
        "SubscriptionId": "7bb42f40...",
        "ActiveDirectoryId": "94367291...",
        "Environment": "AzureCloud",
        "Zone": "orchperfs2.local"
    },
    "PoolDetails": {
        "ConnectionType": "AzureRM",
        "Name": "CVAD_APIs_Resource_Pool",
        "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 200 OK
citrix-transactionid: 47b919ef...
content-Length: 978
content-Type: application/json; charset=utf-8
date: "Wed, 16 Sep 2020 09:42:58 GMT"

{
    "ApplicationId": "aa8f1fd6...",
    "SubscriptionId": "7bb42f40...",
    "ActiveDirectoryId": "94367291...",
    "Environment": "AzureCloud",
    "ManagementEndpoint": "https://management.azure.com/",
    "AuthenticationAuthority": "https://login.microsoftonline.com/",
    "StorageSuffix": "core.windows.net",
    "Capabilities": [
        "AdditionalDiskIndexRemapping",
        "BatchProvisioningPreflightCheck",
        "CreateVmWithNetworkDisconnected",
        "ExtraSpinUptime",
        "PageFileRedirected",
        "PerformsPowerManagementViaHypervisorInterface",
        "ReportsExplicitStorageRequirements",
        "ReportsLocalizedStrings",
        "SupportsMachineCatalogAbortNotify",
        "SupportsMachineCatalogCreationDeletionNotify",
        "SupportsWriteBackCache"
    ],
    "ConfigurationObjectCapabilities": [
        {
            "ResourceType": "Vm",
            "TypeCapabilities": [
                "CpuCount",
                "MemoryMB",
                "MinMemoryMB",
                "HardDiskSizeGB",
                "NetworkMappings"
            ]
        },
        {
            "ResourceType": "Snapshot",
            "TypeCapabilities": [
                "CpuCount",
                "MemoryMB",
                "MinMemoryMB",
                "HardDiskSizeGB",
                "NetworkMappings"
            ]
        }
    ],
    "PluginRevision": "7886dcad...",
    "MaxAbsoluteActiveActions": 100,
    "MaxAbsoluteNewActionsPerMinute": 1000,
    "MaxPowerActionsPercentageOfMachines": 100,
    "ConnectionOptions": null,
    "SupportsLocalStorageCaching": false,
    "SupportsPvsVms": true,
    "ConnectionType": "AzureRM",
    "Addresses": [
        "https://management.azure.com/"
    ],
    "InMaintenanceMode": false,
    "PluginId": "AzureRmFactory",
    "Scopes": [
        {
            "Id": "00000000...",
            "Uid": null,
            "Name": "All",
            "Description": null,
            "IsBuiltIn": true,
            "IsAllScope": true,
            "IsTenantScope": false,
            "TenantId": null,
            "TenantName": null
        }
    ],
    "Tenants": null,
    "UsesCloudInfrastructure": false,
    "Zone": {
        "Id": "00000000...",
        "Uid": 4,
        "Name": "Initial Zone"
    },
    "Id": "19ad12b0...",
    "Name": "CVAD_APIs_CONN",
    "XDPath": "XDHyp:\\Connections\\CVAD_APIs_CONN"
} 
<!--NeedCopy-->

Create a hypervisor in your site using PowerShell

Learn from the following example to create a hypervisor, plus an optional resource pool on the hypervisor within your Citrix DaaS site using any PowerShell code.

function CreateHypervisor {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken,
        [Parameter(Mandatory=$true)]
        [string] $body
    )
    $requestUri = "https://api.cloud.com/cvad/manage/hypervisors"
    $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"
$bearerToken = "ey1.."
$body = @"
{
    "ConnectionDetails": {
        "Name": "CVAD_APIs_CONN",
        "ConnectionType": "AzureRM",
        "ApplicationId": "aa8f1fd6...",
        "ApplicationSecret": "YQ?u...",
        "SubscriptionId": "7bb42f40...",
        "ActiveDirectoryId": "94367291...",
        "Environment": "AzureCloud",
        "Zone": "orchperfs2.local"
    },
    "PoolDetails": {
        "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 = CreateHypervisor $customerid $siteid $bearerToken $body
<!--NeedCopy-->

Create a hypervisor in your site using C# code

Learn from the following example to create a hypervisor, plus an optional resource pool on the hypervisor within your Citrix DaaS site using C# code.

public static async Task<string> CreateHypervisor(
    string customerid,
    string siteid,
    string bearerToken,
    CreateHypervisorRequestModel model)
{
    var requestUri = "https://api.cloud.com/cvad/manage/hypervisors";
    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 hypervisor in your site using Python

Learn from the following example to create a hypervisor, plus an optional resource pool on the hypervisor within your Citrix DaaS site using Python.

import requests

def create_hypervisor(bearerToken, customerid, siteid):
    request_uri = "https://api.cloud.com/cvad/manage/hypervisors"
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }
    payload = json.dumps({
        "ConnectionDetails": {
            "Name": "CVAD_APIs_CONN",
            "ConnectionType": "AzureRM",
            "ApplicationId": "aa8f1fd6...",
            "ApplicationSecret": "YQ?u...",
            "SubscriptionId": "7bb42f40...",
            "ActiveDirectoryId": "94367291...",
            "Environment": "AzureCloud",
            "Zone": "orchperfs2.local"
        },
        "PoolDetails": {
            "ConnectionType": "AzureRM",
            "Name": "CVAD_APIs_Resource_Pool",
            "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-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to create a hypervisor in Citrix DaaS