Azure / azure-powershell

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

Issue with Update-AzWvdScalingPlan cmdlet - Required Fields Error #24043

Open Greygem89 opened 7 months ago

Greygem89 commented 7 months ago

Description

I've encountered an issue while using the Update-AzWvdScalingPlan cmdlet in Azure PowerShell. Despite providing all required fields as per the official Microsoft documentation, I am receiving an error message indicating that certain required fields are missing. The cmdlt is run using powershell runtime 7.2 as part of an automations runbook.

Here is the error message I am receiving:

[400] : ActivityId: c13fd231-59fa-4f7d-9182-995c7dd6c927 Error: ≤{"errors":{"Schedules[0].PeakStartTime":["The PeakStartTime field is required."],"Schedules[0].RampUpStartTime":["The RampUpStartTime field is required."],"Schedules[0].OffPeakStartTime":["The OffPeakStartTime field is required."],"Schedules[0].RampDownStartTime":["The RampDownStartTime field is required."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-238698f4e672f5d31e9a35aa7739a93d-4a045c3e00f7d80f-01"}≥

The fields mentioned in the error message (PeakStartTime, RampUpStartTime, OffPeakStartTime, and RampDownStartTime) are all provided in my script, and I have ensured that they are in the correct format as specified in the Microsoft documentation.

Given that I am following the documentation closely and still encountering this error, I believe there may be an issue with either the Update-AzWvdScalingPlan cmdlet or the documentation itself.

Issue script & Debug output

Update-AzWvdScalingPlan `
  -ResourceGroupName $resourceGroup `
  -Name  $name `
  -Description $description `
  -FriendlyName $friendlyName `
  -TimeZone $timeZone `
  -Schedule @(
    @{
      'Name' =  $scalingPlanName
      'DaysOfWeek' = @("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
      'RampUpStartTime' = @{
        'Hour' = 7
        'Minute' = 0
      }
      'RampUpLoadBalancingAlgorithm' = "DepthFirst"
      'RampUpMinimumHostsPct' = 100
      'RampUpCapacityThresholdPct' = 100
      'PeakStartTime' = @{
        'Hour' = 8
        'Minute' = 0
      }
      'PeakLoadBalancingAlgorithm' = "DepthFirst"
      'PeakMinimumHostsPct' = 100
      'RampDownStartTime' = @{
        'Hour' = 20
        'Minute' = 0
      }
      'RampDownLoadBalancingAlgorithm' = "DepthFirst"
      'RampDownStopHostsWhen' = "ZeroSessions"
      'RampDownNotificationSnoozeEnabled' = $false
      'OffPeakStartTime' = @{
        'Hour' = 18
        'Minute' = 0
      }
      'OffPeakLoadBalancingAlgorithm' = "DepthFirst"
    }
  ) `
  -HostPoolReference @(
    @{
      'HostPoolArmPath' = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.DesktopVirtualization/hostPools/$hostpoolName";
      'ScalingPlanEnabled' = $false;
    }
  )

Environment data

automation runbook using powershell runtime 7.2 az module installed is 11.2 for runtime 7.2

Name                           Value
----                           -----
PSVersion                      7.2.0
PSEdition                      Core
GitCommitId                    7.2.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.15.0                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContex…
Script     3.1.1                 Az.DesktopVirtualization            {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImag…

Error output

[400] : ActivityId: c13fd231-59fa-4f7d-9182-995c7dd6c927 Error: ≤{"errors":{"Schedules[0].PeakStartTime":["The PeakStartTime field is required."],"Schedules[0].RampUpStartTime":["The RampUpStartTime field is required."],"Schedules[0].OffPeakStartTime":["The OffPeakStartTime field is required."],"Schedules[0].RampDownStartTime":["The RampDownStartTime field is required."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-238698f4e672f5d31e9a35aa7739a93d-4a045c3e00f7d80f-01"}≥
isra-fel commented 7 months ago

@Alex-wdy hey Alex, the DesktopVirtualization label isn't working. Could you help set up the contact info? Thanks.

Alex-wdy commented 7 months ago

DesktopVirtualization

I have set the following two dev as owners of Az.DesktopVirtualization. Please let me know if there are any updates. @alec-baird @costinhagiu

alec-baird commented 7 months ago

Investigating, will update with my findings.

dallinlmag commented 7 months ago

@Greygem89

It looks like the docs you are following are for a newer version of the Powershell Module.

There are two options for you here:

  1. Update your Az.DesktopVirtualization Powershell module. Your current script will run properly on a newer version of the module.
  2. Use these docs to keep using the same PS module version Update-AzWvdScalingPlan See the string types for the start times like RampUpStartTime.

You will also need to add "RampDownCapacityThresholdPct" and make sure your OffPeakStartTime is After the RampDownStartTime.

If you do update your PS module and you just want to change the schedule, you can take advantage of update-azwvdscalingplanpooledschedule. It makes it so you don't have to specify all properties of the schedule to update.

Greygem89 commented 7 months ago

I was certain I was running on the latest module since I was using a runbook to run it and was using the newest available there. I'll double check tomorrow if its possible to upgrade the module to a newer version.

On Thu, 1 Feb 2024, 22:25 Dallin Magleby, @.***> wrote:

@Greygem89 https://github.com/Greygem89

It looks like the docs you are following are for a newer version of the Powershell Module.

There are two options for you here:

  1. Update your Az.DesktopVirtualization Powershell module. Your current script will run properly on a newer version of the module.
  2. Use these docs to keep using the same PS module version Update-AzWvdScalingPlan https://learn.microsoft.com/en-us/powershell/module/az.desktopvirtualization/update-azwvdscalingplan?view=azps-10.4.1 See the string types for the start times like RampUpStartTime.

You will also need to add "RampDownCapacityThresholdPct" and make sure your OffPeakStartTime is After the RampDownStartTime.

If you do update your PS module and you just want to change the schedule, you can take advantage of update-azwvdscalingplanpooledschedule https://learn.microsoft.com/en-us/powershell/module/az.desktopvirtualization/update-azwvdscalingplanpooledschedule?view=azps-11.2.0. It makes it so you don't have to specify all properties of the schedule to update.

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-powershell/issues/24043#issuecomment-1922273735, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMHBBUTJHW4ENXM3A3TH3DYRQB6NAVCNFSM6AAAAABCKU3P7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRSGI3TGNZTGU . You are receiving this because you were mentioned.Message ID: @.***>