gpt4 book ai didi

azure - 是否有解决方案来设置动态 Windows 虚拟桌面主机池负载平衡方法?

转载 作者:行者123 更新时间:2023-12-03 05:40:07 25 4
gpt4 key购买 nike

我想每天晚上 19​​ 点到上午 11 点将主机池负载均衡方法从广度优先更改为深度优先,以降低虚拟机的成本。

例如:主机池负载均衡方法:呼吸优先,上午 11:00 ~ 下午 17:00主机池负载均衡方法:深度优先,17:00 PM ~ 11:00 AM

有知道这方面情况的人吗?引用:SET-Hostpool

最佳答案

您可以使用 azure 自动化 Runbook 来执行此操作,请按照以下步骤操作。

1.导航到 azure 门户,create an automation account ,然后创建一个powershell runbook

2.导航到自动化帐户 -> 模块 -> 浏览库 -> 搜索 powershell 模块 Microsoft.RDInfra.RDPowerShell并导入,导入后如下所示。

enter image description here

3.当您创建自动化帐户时,将创建 Azure 运行方式帐户设置为,它将在您的 Azure 中创建一个 AD 应用程序以及服务主体AD 租户,其名称类似于 automationaccountname_fc2Wgay6EkHrpgrpMSbF1V8uc6LVDkz9tgb8T6YUhaQ=。在azure runbook中,您无法使用交互方式登录虚拟桌面,因此选项是使用服务主体(运行帐户)登录。

登录之前,您需要创建角色分配,以便服务主体可以登录虚拟桌面,只需按照此 link 操作即可.

Add-RdsAccount -DeploymentUrl "https://rdbroker.wvd.microsoft.com"
Get-RdsTenant

$myTenantName = "<Windows Virtual Desktop Tenant Name>"
New-RdsRoleAssignment -RoleDefinitionName "RDS Owner" -ApplicationId <service-principal-appid> -TenantName $myTenantName

要在上面的脚本中查找 ApplicationId,请导航到门户中的 Azure Active Directory -> 应用注册 -> 所有应用程序 -> 找到您的运行方式帐户的 AD 应用程序 -> 获取 ApplicationId,如下所示。

enter image description here

4.导航到步骤 1 中创建的 powershell Runbook,使用如下脚本,它将主机池设置为使用广度优先负载平衡。

$connectionName = "AzureRunAsConnection"
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName

"Logging in to Windows Virtual Desktop..."
Add-RdsAccount `
-DeploymentUrl "https://rdbroker.wvd.microsoft.com" `
-AadTenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}

Set-RdsHostPool -TenantName "<contoso>" -Name "<contosoHostPool>" -BreadthFirstLoadBalancer

然后保存 runbook1,并创建另一个 runbook2,使用下面的脚本,它将主机池设置为使用深度优先负载平衡。

$connectionName = "AzureRunAsConnection"
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName

"Logging in to Windows Virtual Desktop..."
Add-RdsAccount `
-DeploymentUrl "https://rdbroker.wvd.microsoft.com" `
-AadTenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}

Set-RdsHostPool -TenantName "<contoso>" -Name "<contosoHostPool>" -DepthFirstLoadBalancer -MaxSessionLimit 10

5.导航到 runbook1 中的 Schedule,有关如何使用它的更多详细信息,请参阅此 doc 。例如,在您的情况下,只需如下设置即可。然后 runbook1 将在每天 11:00 AM 运行。在 runbook2 中,也是同样的逻辑,那么 runbook2 会在每天17:00 PM运行。配置计划后,对两个 Runbook 进行分层。

enter image description here

关于azure - 是否有解决方案来设置动态 Windows 虚拟桌面主机池负载平衡方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59495308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com