How to create a machine catalog in Citrix DaaS
Use REST APIs to create a machine catalog in your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) site. The VMs in machine catalog are provisioned using Machine Creation Services (MCS).
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 machine catalog 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 created a connection and resource pool in
hosting
. - Make sure you have a domain administrator account.
- Invoke the API described in this document from a client host or from the API exploration tab to create a MCS machine catalog.
- MCS doesn’t support provisioning persistent static catalogs using the Full Clone method when a multi-session OS VM is used as the master image.
Create a machine catalog using any REST API tool
Learn from the following example to create a machine catalog in your Citrix DaaS site using any REST API tool.
Request
POST https://api.cloud.com/cvad/manage/MachineCatalogs 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
X-AdminCredential: Basic YWRtaW5p...
{
"Name": "CVAD_APIs_MCS_Catalog",
"AllocationType": "Static",
"MinimumFunctionalLevel": "L7_25",
"PersistUserChanges": "Discard",
"ProvisioningType": "MCS",
"SessionSupport": "MultiSession",
"Zone": "My Resource Location",
"ProvisioningScheme": {
"MasterImagePath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool\\image.folder\\studio-develop.resourcegroup\\studiodevelopdisks.storageaccount\\vhds.container\\studio-vdi20181218160200.vhd.vhd",
"CpuCount": null,
"MemoryMB": null,
"NumTotalMachines": 2,
"NetworkMapping": [
{
"DeviceNameOrId": "default",
"NetworkDeviceNameOrId": "0",
"NetworkPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool\\virtualprivatecloud.folder\\studio-develop.resourcegroup\\studio-develop-vnet.virtualprivatecloud\\default.network"
}
],
"MachineAccountCreationRules": {
"NamingScheme": "MCS-VDA##",
"NamingSchemeType": "Numeric",
"Domain": "orchperfs2.local",
"OU": ""
},
"PrepareImage": true,
"DedicatedTenancy": false,
"SecurityGroups": null,
"UseFullDiskCloneProvisioning": false,
"CustomProperties": [
{
"Name": "UseManagedDisks",
"Value": "true"
},
{
"Name": "StorageAccountType",
"Value": "Premium_LRS"
},
{
"Name": "LicenseType",
"Value": "Windows_Server"
}
],
"ServiceOfferingPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool\\serviceoffering.folder\\Standard_B2ms.serviceoffering"
}
}
<!--NeedCopy-->
Response
HTTP/1.1 200 OK
citrix-transactionid: a895c8e0...
content-Length: 1341
content-Type: application/json; charset=utf-8
date: "Thu, 17 Sep 2020 08:17:18 GMT"
{
"AgentVersion": "-",
"HypervisorConnection": {
"Id": "e07c3501...",
"Uid": 5,
"Name": "CVAD_APIs_CONN"
},
"OSType": "-",
"OSVersion": "-",
"DeliveryGroups": [],
"Name": "CVAD_APIs_MCS_Catalog",
"Id": "3eeb3230...",
"Uid": 4,
"AllocationType": "Random",
"AssignedCount": 0,
"AvailableAssignedCount": 0,
"AvailableCount": 0,
"AvailableUnassignedCount": 0,
"Description": null,
"IsPowerManaged": true,
"IsRemotePC": false,
"JobsInProgress": null,
"MachineType": "Virtual",
"MinimumFunctionalLevel": "L7_25",
"HasBeenPromoted": false,
"HasBeenPromotedFrom": "Unknown",
"CanRollbackVMImage": false,
"PersistChanges": "Discard",
"ProvisioningScheme": {
"CleanOnBoot": true,
"ControllerAddresses": [],
"CpuCount": 0,
"CoresPerCpuCount": 0,
"CurrentDiskImage": {
"FunctionalLevel": null,
"Image": {
"RelativePath": null,
"FullRelativePath": null,
"ResourceType": "Vhd",
"Id": "studio-develop/studiodevelopdisks/vhds/studio-vdi20181218160200.vhd",
"Name": "studio-vdi20181218160200.vhd",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool\\image.folder\\studio-develop.resourcegroup\\studiodevelopdisks.storageaccount\\vhds.container\\studio-vdi20181218160200.vhd.vhd"
},
"ImageStatus": "Unknown",
"Date": "0001-01-01T00:00:00.000+00:00"
},
"CustomProperties": null,
"DedicatedTenancy": false,
"DiskSizeGB": 0,
"GpuTypeId": null,
"ResourcePool": {
"FullRelativePath": "",
"Hypervisor": {
"Id": "e07c3501...",
"Uid": 5,
"Name": "CVAD_APIs_CONN"
},
"Id": "926a0c47...",
"Name": "CVAD_APIs_Resource_Pool",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool"
},
"IdentityPool": null,
"MachineCount": 0,
"MasterImage": {
"RelativePath": null,
"FullRelativePath": null,
"ResourceType": "Vhd",
"Id": "studio-develop/studiodevelopdisks/vhds/studio-vdi20181218160200.vhd",
"Name": "studio-vdi20181218160200.vhd",
"XDPath": "XDHyp:\\HostingUnits\\CVAD_APIs_Resource_Pool\\image.folder\\studio-develop.resourcegroup\\studiodevelopdisks.storageaccount\\vhds.container\\studio-vdi20181218160200.vhd.vhd"
},
"MemoryMB": 0,
"NetworkMaps": [
{
"DeviceName": "0",
"DeviceId": "0",
"Network": {
"RelativePath": null,
"FullRelativePath": null,
"ResourceType": "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"
},
"IsCardEnabled": true
}
],
"NutanixContainer": null,
"ResetAdministratorPasswords": false,
"SecurityGroups": [],
"ServiceOffering": "Standard_B2ms",
"UseFullDiskCloneProvisioning": true,
"UseWriteBackCache": false,
"VMMetadata": null,
"WriteBackCacheDiskIndex": null,
"WriteBackCacheDiskSizeGB": 0,
"WriteBackCacheMemorySizeMB": 0,
"IsPreviousImageLegacyVda": false,
"MachineAccountCreationRules": null,
"NumAvailableMachineAccounts": 0
},
"ProvisioningType": "MCS",
"ProvisioningProgress": null,
"PvsAddress": null,
"PvsDomain": null,
"RemotePCEnrollmentScopes": null,
"Scopes": [],
"Tenants": null,
"SessionSupport": "MultiSession",
"SharingKind": "Unknown",
"TotalCount": 0,
"IsBroken": false,
"Errors": [],
"Warnings": [],
"UnassignedCount": 0,
"UsedCount": 0,
"Zone": {
"Id": "41e85452...",
"Uid": null,
"Name": "My Resource Location"
}
}
<!--NeedCopy-->
Create a machine catalog using PowerShell
Learn from the following example to create a machine catalog in your Citrix DaaS site using any PowerShell code.
function CreateMachineCatalog {
param (
[Parameter(Mandatory=$true)]
[string] $customerid,
[Parameter(Mandatory=$true)]
[string] $siteid,
[Parameter(Mandatory=$true)]
[string] $bearerToken,
[Parameter(Mandatory=$true)]
[string] $adminCredential,
[Parameter(Mandatory=$true)]
[string] $body
)
$requestUri = "https://api.cloud.com/cvad/manage/MachineCatalogs"
$headers = @{
"Accept" = "application/json";
"Content-Type"="application/json";
"Authorization" = "CWSAuth Bearer=$bearerToken";
"Citrix-CustomerId" = $customerid;
"Citrix-InstanceId" = $siteid;
"X-AdminCredential" = "Basic $adminCredential";
}
$response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body
return $response
}
$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$bearerToken = "ey1..."
$adminCredential = "YWRtaW5p..."
$body = @"
{
"Name": "CVAD_APIs_MCS_MC",
"AllocationType": "Static",
"IsRemotePC": false,
"MachineType": "Virtual",
"MinimumFunctionalLevel": "L7_9",
"PersistUserChanges": "Discard",
"ProvisioningType": "MCS",
"SessionSupport": "MultiSession"
}
"@
$response = CreateMachineCatalog $customerid $siteid $bearerToken $adminCredential $body
<!--NeedCopy-->
Create a machine catalog using C# code
Learn from the following example to create a machine catalog in your Citrix DaaS site using any C# code.
public static async Task<string> CreateMachineCatalog(
string customerid,
string siteid,
string adminCredential,
string bearerToken,
CreateMachineCatalogRequestModel model)
{
var requestUri = "https://api.cloud.com/cvad/manage/MachineCatalogs"
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.Add("X-AdminCredential", "Basic " + adminCredential);
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 machine catalog using Python
Learn from the following example to create a machine catalog in your Citrix DaaS site using Python.
import requests
def create_machine_catalog(bearerToken, adminCredential, customerid, siteid):
request_uri = "https://api.cloud.com/cvad/manage/MachineCatalogs"
headers = {
'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
'Citrix-CustomerId': customerid,
'Citrix-InstanceId': siteid,
'X-AdminCredential': adminCredential,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
payload = json.dumps({
"Name": "CVAD_APIs_MCS_MC",
"AllocationType": "Static",
"IsRemotePC": false,
"MachineType": "MCS",
"MinimumFunctionalLevel": "L7_9",
"PersistUserChanges": "Discard",
"ProvisioningType": "Manual",
"SessionSupport": "MultiSession"
})
response = requests.post(request_uri, headers = headers, verify = False, data = payload)
return response.json()
<!--NeedCopy-->