Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

New-AzWvdScalingPlan -Schedule wrong time format (should be HH:mm) #16486

Closed tmmjelde closed 1 month ago

tmmjelde commented 2 years ago

Description

This is an example of a "working" command: New-AzWvdScalingPlan -ResourceGroupName ResourceGroupName -Name Name -Location 'westeurope' -HostPoolType 'Pooled' -TimeZone 'W. Europe Standard Time' -Schedule @( @{ 'name' = 'Weekends'; 'daysOfWeek' = @('Saturday', 'Sunday'); 'rampUpStartTime' = '1900-01-01T06:30:00Z'; 'rampUpLoadBalancingAlgorithm' = 'BreadthFirst'; 'rampUpMinimumHostsPct' = 10; 'rampUpCapacityThresholdPct' = 80; 'peakStartTime' = '1900-01-01T09:00:00Z'; 'peakLoadBalancingAlgorithm' = 'DepthFirst'; 'RampDownStartTime' = '1900-01-01T18:00:00Z'; 'rampDownLoadBalancingAlgorithm' = 'DepthFirst'; 'rampDownMinimumHostsPct' = 10; 'rampDownCapacityThresholdPct' = 80; 'rampDownForceLogoffUser' = $false; 'rampDownWaitTimeMinute' = 30; 'rampDownNotificationMessage' = 'You will be logged off in 30 min. Make sure to save your work.'; 'rampDownStopHostsWhen' = 'ZeroSessions'; 'offPeakStartTime' = '1900-01-01T20:00:00Z'; 'offPeakLoadBalancingAlgorithm' = 'DepthFirst'; } )

Creation "works" just fine. No errors in Powershell. However, go into the Azure portal and review the schedule. It will tell you the format is wrong for the following: rampUpStartTime, peakStartTime, RampDownStartTime, offPeakStartTime

These require HH:mm format. As such, a good example would be this:

New-AzWvdScalingPlan -ResourceGroupName ResourceGroupName -Name Name -Location 'westeurope' -HostPoolType 'Pooled' -TimeZone 'W. Europe Standard Time' -Schedule @( @{ 'name' = 'Weekends'; 'daysOfWeek' = @('Saturday', 'Sunday'); 'rampUpStartTime' = '06:30'; 'rampUpLoadBalancingAlgorithm' = 'BreadthFirst'; 'rampUpMinimumHostsPct' = 10; 'rampUpCapacityThresholdPct' = 80; 'peakStartTime' = '09:00'; 'peakLoadBalancingAlgorithm' = 'DepthFirst'; 'RampDownStartTime' = '18:00'; 'rampDownLoadBalancingAlgorithm' = 'DepthFirst'; 'rampDownMinimumHostsPct' = 10; 'rampDownCapacityThresholdPct' = 80; 'rampDownForceLogoffUser' = $false; 'rampDownWaitTimeMinute' = 30; 'rampDownNotificationMessage' = 'You will be logged off in 30 min. Make sure to save your work.'; 'rampDownStopHostsWhen' = 'ZeroSessions'; 'offPeakStartTime' = '20:00'; 'offPeakLoadBalancingAlgorithm' = 'DepthFirst'; } )

But this fails in Powershell.

Please change the powershell requirements to support HH:mm format, as the Azure portal specifies is required.

Also, this parameter is mislabeled: rampDownWaitTimeMinute should be rampDownWaitTimeMinutes. Check the ARM template to verify this.

Issue script & Debug output

$ResourceGroupName = "..."
$Name = "testscalingplan"
New-AzWvdScalingPlan `
            -ResourceGroupName $ResourceGroupName `
            -Name $Name `
            -Location 'westeurope' `
            -HostPoolType 'Pooled' `
            -TimeZone 'W. Europe Standard Time' `
            -Schedule @(
        @{
                        'name'                           = 'Weekends';
                        'daysOfWeek'                     = @('Saturday', 'Sunday');
                        'rampUpStartTime'                = "06:30";
                        'rampUpLoadBalancingAlgorithm'   = 'BreadthFirst';
                        'rampUpMinimumHostsPct'          = 10;
                        'rampUpCapacityThresholdPct'     = 80;
                        'peakStartTime'                  = "09:00";
                        'peakLoadBalancingAlgorithm'     = 'DepthFirst';
                        'RampDownStartTime'              = "18:00";
                        'rampDownLoadBalancingAlgorithm' = 'DepthFirst';
                        'rampDownMinimumHostsPct'        = 10;
                        'rampDownCapacityThresholdPct'   = 80;
                        'rampDownForceLogoffUser'        = $false;
                        'rampDownWaitTimeMinute'         = 30;
                        'rampDownNotificationMessage'    = 'You will be logged off in 30 min. Make sure to save your work.';
                        'rampDownStopHostsWhen'          = 'ZeroSessions';
                        'offPeakStartTime'               = "20:00";
                        'offPeakLoadBalancingAlgorithm'  = 'DepthFirst';
                    }
                )

DEBUG: 14:23:23 - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: [CmdletProcessRecordAsyncStart]: Created new QosEvent for command 'New-AzWvdScalingPlan_CreateExpanded'
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/.../resourceGroups/.../providers/Microsoft.DesktopVirtualization/scalingPlans/testscalingplan?api-version=2021-07-12
DEBUG: RequestCreated: /subscriptions/.../resourceGroups/.../providers/Microsoft.DesktopVirtualization/scalingPlans/testscalingplan?api-version=2021-07-12
DEBUG: HeaderParametersAdded:
DEBUG: BodyContentSet:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/.../resourceGroups/.../providers/Microsoft.DesktopVirtualization/scalingPlans/testscalingplan?api-version=2021-07-12

Headers:
x-ms-unique-id                : 22
x-ms-client-request-id        : ...
CommandName                   : New-AzWvdScalingPlan
FullCommandName               : New-AzWvdScalingPlan_CreateExpanded
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v0.0.0,PSVersion/v5.1.22000.282

Body:
{
  "location": "westeurope",
  "properties": {
    "timeZone": "W. Europe Standard Time",
    "hostPoolType": "Pooled",
    "schedules": [
      {
        "name": "Weekends",
        "daysOfWeek": [
          "Saturday",
          "Sunday"
        ],
        "rampUpLoadBalancingAlgorithm": "BreadthFirst",
        "rampUpMinimumHostsPct": 10,
        "rampUpCapacityThresholdPct": 80,
        "peakLoadBalancingAlgorithm": "DepthFirst",
        "rampDownLoadBalancingAlgorithm": "DepthFirst",
        "rampDownMinimumHostsPct": 10,
        "rampDownCapacityThresholdPct": 80,
        "rampDownForceLogoffUsers": false,
        "rampDownStopHostsWhen": "ZeroSessions",
        "rampDownWaitTimeMinutes": 30,
        "rampDownNotificationMessage": "You will be logged off in 30 min. Make sure to save your work.",
        "offPeakLoadBalancingAlgorithm": "DepthFirst"
      }
    ]
  }
}

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
InternalServerError

Headers:
Pragma                        : no-cache
x-ms-failure-cause            : service
x-ms-opsarmpath64             : ==
x-ms-lamport-ts               : 1845091486
x-ms-correlation-id           : ...
x-ms-request-id               : ...
Cache-Control                 : no-cache
Set-Cookie                    : ...
Server                        : Microsoft-IIS/10.0
X-Powered-By                  : ASP.NET
x-ms-ratelimit-remaining-subscription-writes: 1198
x-ms-correlation-request-id   : ...
x-ms-routing-request-id       : NORWAYEAST:20211124T132326Z:...
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Wed, 24 Nov 2021 13:23:26 GMT
Connection                    : close

Body:
{
  "error": {
    "code": "1",
    "message": "UnknownError",
    "target": "ArmBaseExceptionFilter.OnException",
    "details": [
      {
        "code": "NullReferenceException",
        "message": "Object reference not set to an instance of an object.",
        "target": "Microsoft.RDInfra.ArmDataModel"
      }
    ]
  }
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
New-AzWvdScalingPlan : UnknownError
At line:1 char:1
+ New-AzWvdScalingPlan `
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ SubscriptionI...2.ScalingPlan }:<>f__AnonymousType18`4) [New-AzWvdScalingPlan_CreateExpanded], Exception
    + FullyQualifiedErrorId : 1,Microsoft.Azure.PowerShell.Cmdlets.DesktopVirtualization.Cmdlets.NewAzWvdScalingPlan_CreateExpanded
DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.DesktopVirtualization:3.1.0.0; CommandName: New-AzWvdScalingPlan_CreateExpanded; PSVersion: 5.1.22000.282; IsSuccess: False; Duration: 00:00:00; Exception: InternalException;
DEBUG: Finish sending metric.
DEBUG: CmdletEndProcessing:

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.6.2      Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script     3.1.0      Az.DesktopVirtualization            {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImage, Get-AzWvdApplication, Get-AzWvdApplicationGroup...}

Error output

No response

dingmeng-xue commented 2 years ago

Thank you for your reporting. Tagging and routing to the team member best able to assist.

SaurabhSharma-MSFT commented 2 years ago

@tmmjelde We are looking into it and get back to you.

alec-baird commented 1 month ago

We updated our latest Powershell release to change from DateTime string objects to custom objects. Please upgrade to latest stable powershell release.