Jump to content
Updated Privacy Statement
  • 0

how to add azure host connection through powershell citrix 7.18


Question

3 answers to this question

Recommended Posts

  • 0

Hi Sadhana10, here is a sample script that created service principal for subscription and hosting connection object and resources. This script assumes you have installed Azure PowerShell provider along with Virtual Apps and Desktops Remote PowerShell SDK on the same machine. Hope this helps.

 

# Sample script to create Hosting Connection and Hypervisor for Microsoft Azure
Add-PSSnapin Citrix*

# Function creates subscription scope service principal [https://support.citrix.com/article/CTX219243]
function createServicePrincipal($subId, $appName, [SecureString]$appPassword) {
    $application = New-AzADApplication -DisplayName $appName -HomePage "https://localhost/$appName" -IdentifierUris "https://$appName" -Password $appPassword
    New-AzADServicePrincipal -ApplicationId $application.ApplicationId
    # Wait for the service principal to become available
    Start-Sleep -s 60
    New-AzRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $application.ApplicationId -scope "/subscriptions/$subId"
    return $application.ApplicationId
}

# Variables
$azureAppName = "CVAD-SubscriptionScopeSP"
[SecureString]$azureAppPassword = "<secure password for service principal>" | ConvertTo-SecureString -AsPlainText -Force
$azureSubscription = "<azure subscription id>"
$azureTenant = "<azure subscription tenant id>"
$azureRegion = "<azure region name>"
$azureResourceGroup = "<azure resource group name>"
$azureVNet = "<azure virtual network name>"
$azureSubnet = "<azure subnet name>"
$connectionName = "<citrix hosting connecttion name>"
$hostingName = "<citrix hosting connecttion hypervisor name>"
$configZone = Get-ConfigZone -Name "<citrix zone name>"
$username = createServicePrincipal -subId $azureSubscription -appName $azureAppName -appPassword $azureAppPassword

Set-HypAdminConnection
$connObject = New-Item -ConnectionType "Custom" -CustomProperties "<CustomProperties xmlns=`"http://schemas.citrix.com/2014/xd/machinecreation`" xmlns:xsi=`"http://www.w3.org/2001/XMLSchema-instance`"><Property xsi:type=`"StringProperty`" Name=`"SubscriptionId`" Value=`"$azureSubscription`" /><Property xsi:type=`"StringProperty`" Name=`"ManagementEndpoint`" Value=`"https://management.azure.com/`" /><Property xsi:type=`"StringProperty`" Name=`"AuthenticationAuthority`" Value=`"https://login.microsoftonline.com/`" /><Property xsi:type=`"StringProperty`" Name=`"StorageSuffix`" Value=`"core.windows.net`" /><Property xsi:type=`"StringProperty`" Name=`"azureTenant`" Value=`"$azureTenant`" /></CustomProperties>" -HypervisorAddress @("https://management.azure.com/") -Path @("XDHyp:\Connections\$connectionName") -Persist -PluginId "AzureRmFactory" -Scope @() -SecurePassword $azureAppPassword -UserName $userName -ZoneUid $configZone.Uid
New-BrokerHypervisorConnection -HypHypervisorConnectionUid $connObject.HypervisorConnectionUid
New-Item -HypervisorConnectionName $connObject.HypervisorConnectionName -NetworkPath @("XDHyp:\Connections\$connectionName\$azureRegion.region\virtualprivatecloud.folder\$azureResourceGroup.resourcegroup\$azureVNet.virtualprivatecloud\$azureSubnet.network") -Path @("XDHyp:\HostingUnits\$hostingName") -PersonalvDiskStoragePath @() -RootPath "XDHyp:\Connections\$connectionName\$azureRegion.region" -StoragePath @()

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...