Azure Logic App 및 실행 일정 만들기

완료됨

다음으로, Azure Logic App을 만들고 새 크기 조정 도구의 실행 일정을 설정해야 합니다.

  1. Windows PowerShell을 엽니다.
  2. 다음 cmdlet을 실행하여 Azure 계정에 로그인합니다.
Login-AzAccount

  1. 다음 cmdlet을 실행하여 Azure Logic App을 만들기 위한 스크립트를 다운로드합니다.
New-Item -ItemType Directory -Path "C:\Temp" -Force
Set-Location -Path "C:\Temp"
$Uri = "https://raw.githubusercontent.com/Azure/RDS-Templates/master/wvd-templates/wvd-scaling-script/CreateOrUpdateAzLogicApp.ps1"
# Download the script
Invoke-WebRequest -Uri $Uri -OutFile ".\CreateOrUpdateAzLogicApp.ps1"

  1. 다음 PowerShell 스크립트를 실행하여 호스트 풀에 대한 Azure Logic App 및 실행 일정을 만듭니다.

참고

자동 크기 조정을 수행하려는 각 호스트 풀에 대해 이 스크립트를 실행해야 하지만 Azure Automation 계정은 하나만 필요합니다.

$AADTenantId = (Get-AzContext).Tenant.Id

$AzSubscription = Get-AzSubscription | Out-GridView -OutputMode:Single -Title "Select your Azure Subscription"
Select-AzSubscription -Subscription $AzSubscription.Id

$ResourceGroup = Get-AzResourceGroup | Out-GridView -OutputMode:Single -Title "Select the resource group for the new Azure Logic App"

$AVDHostPool = Get-AzResource -ResourceType "Microsoft.DesktopVirtualization/hostpools" | Out-GridView -OutputMode:Single -Title "Select the host pool you'd like to scale"

$LogAnalyticsWorkspaceId = Read-Host -Prompt "If you want to use Log Analytics, enter the Log Analytics Workspace ID returned by when you created the Azure Automation account, otherwise leave it blank"
$LogAnalyticsPrimaryKey = Read-Host -Prompt "If you want to use Log Analytics, enter the Log Analytics Primary Key returned by when you created the Azure Automation account, otherwise leave it blank"
$RecurrenceInterval = Read-Host -Prompt "Enter how often you'd like the job to run in minutes, for example, '15'"
$BeginPeakTime = Read-Host -Prompt "Enter the start time for peak hours in local time, for example, 9:00"
$EndPeakTime = Read-Host -Prompt "Enter the end time for peak hours in local time, for example, 18:00"
$TimeDifference = Read-Host -Prompt "Enter the time difference between local time and UTC in hours, for example, +5:30"
$SessionThresholdPerCPU = Read-Host -Prompt "Enter the maximum number of sessions per CPU that will be used as a threshold to determine when new session host VMs need to be started during peak hours"
$MinimumNumberOfRDSH = Read-Host -Prompt "Enter the minimum number of session host VMs to keep running during off-peak hours"
$MaintenanceTagName = Read-Host -Prompt "Enter the name of the Tag associated with VMs you don't want to be managed by this scaling tool"
$LimitSecondsToForceLogOffUser = Read-Host -Prompt "Enter the number of seconds to wait before automatically signing out users. If set to 0, any session host VM that has user sessions, will be left untouched"
$LogOffMessageTitle = Read-Host -Prompt "Enter the title of the message sent to the user before they are forced to sign out"
$LogOffMessageBody = Read-Host -Prompt "Enter the body of the message sent to the user before they are forced to sign out"

$AutoAccount = Get-AzAutomationAccount | Out-GridView -OutputMode:Single -Title "Select the Azure Automation account"
$AutoAccountConnection = Get-AzAutomationConnection -ResourceGroupName $AutoAccount.ResourceGroupName -AutomationAccountName $AutoAccount.AutomationAccountName | Out-GridView -OutputMode:Single -Title "Select the Azure RunAs connection asset"

$WebhookURIAutoVar = Get-AzAutomationVariable -Name 'WebhookURIARMBased' -ResourceGroupName $AutoAccount.ResourceGroupName -AutomationAccountName $AutoAccount.AutomationAccountName

$Params = @{
    "AADTenantId"                  = $AADTenantId                            # Optional. If not specified, it will use the current Azure context
    "SubscriptionID"                = $AzSubscription.Id                      # Optional. If not specified, it will use the current Azure context
    "ResourceGroupName"            = $ResourceGroup.ResourceGroupName        # Optional. Default: "AVDAutoScaleResourceGroup"
    "Location"                      = $ResourceGroup.Location                  # Optional. Default: "West US2"
    "UseARMAPI"                    = $true
    "HostPoolName"                  = $AVDHostPool.Name
    "HostPoolResourceGroupName"    = $AVDHostPool.ResourceGroupName          # Optional. Default: same as ResourceGroupName param value
    "LogAnalyticsWorkspaceId"      = $LogAnalyticsWorkspaceId                # Optional. If not specified, script will not log to the Log Analytics
    "LogAnalyticsPrimaryKey"        = $LogAnalyticsPrimaryKey                  # Optional. If not specified, script will not log to the Log Analytics
    "ConnectionAssetName"          = $AutoAccountConnection.Name              # Optional. Default: "AzureRunAsConnection"
    "RecurrenceInterval"            = $RecurrenceInterval                      # Optional. Default: 15
    "BeginPeakTime"                = $BeginPeakTime                          # Optional. Default: "09:00"
    "EndPeakTime"                  = $EndPeakTime                            # Optional. Default: "17:00"
    "TimeDifference"                = $TimeDifference                          # Optional. Default: "-7:00"
    "SessionThresholdPerCPU"        = $SessionThresholdPerCPU                  # Optional. Default: 1
    "MinimumNumberOfRDSH"          = $MinimumNumberOfRDSH                    # Optional. Default: 1
    "MaintenanceTagName"            = $MaintenanceTagName                      # Optional.
    "LimitSecondsToForceLogOffUser" = $LimitSecondsToForceLogOffUser          # Optional. Default: 1
    "LogOffMessageTitle"            = $LogOffMessageTitle                      # Optional. Default: "Machine is about to shutdown."
    "LogOffMessageBody"            = $LogOffMessageBody                      # Optional. Default: "Your session will be logged off. Please save and close everything."
    "WebhookURI"                    = $WebhookURIAutoVar.Value
}

.\CreateOrUpdateAzLogicApp.ps1 @Params

스크립트를 실행한 후 다음 그림처럼 Azure Logic App이 리소스 그룹에 표시됩니다.

An image of Azure Logic App appearing in a resource group.

되풀이 간격 또는 표준 시간대 변경과 같이 실행 일정을 변경하려면 Azure Logic Apps 자동 크기 조정 스케줄러로 이동하고 편집을 선택하여 Azure Logic Apps 디자이너로 이동합니다.

An image of how to make changes to the execution schedule.