Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.87k forks source link

New-AzPolicyAssignment PolicyParameterObject incorrect translated #26424

Open S-dn-Y opened 1 month ago

S-dn-Y commented 1 month ago

Description

Hi everybody,

We rely on a PolicyParameterObject for assigning a policy and in the latest version(s) the object is converted in a way that it breaks our code. Following the docs I create a hashtable where the key is the parameter's name, the value is an array of strings that represent allowed images or excluded VM ids. The errors are listed below in the debug output.

I've found that the convert helper function that was added in https://github.com/Azure/azure-powershell/pull/24762 and/or https://github.com/Azure/azure-powershell/pull/25293 converts my array of strings (which seem to be wrapped inside a PSObject) to a hashtable as the helper function iterates to the PSObject's properties and outputs the Length property as a hashtable.

I've removed the signature and changed the function and the function works if I add another If statement so strings will just be returned as is:

# traverse collections to ensure nested values are all processed
if ($InputObject -is [hashtable]) {
    $returnValue = @{}
    foreach ($key in $InputObject.Keys) {
        $returnValue[$key] = (ConvertParameterInput $InputObject[$key])
    }

    return $returnValue
}
elseif ($InputObject -is [array]) {
    $returnValue = @()
    foreach ($object in $InputObject) {
        $returnValue += (ConvertParameterInput $object)
    }

    return ,$returnValue
}
elseif ($InputObject -is [System.String])
{
    return $InputObject
}
elseif ($InputObject -is [PSObject])
{
    $returnValue = @{}
    foreach ($property in $InputObject.PSObject.Properties) {
        $returnValue[$property.Name] = (ConvertParameterInput $property.Value)
    }

    return $returnValue
}
else {
    return $InputObject
}

I've added some verbose output in the script before I changed it to show what happens:

> PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> ConvertParameterObject -InputObject $DENonApprovedWinVMImageParameterObject 
> VERBOSE: Input object is an hashtable.. which is expected.
> VERBOSE: Converting parameter input on key 'excludedVMResourceIDs'.
> VERBOSE: Parameter is an array. Still expected.
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-D10001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-D10001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-D10001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-D10001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-D10002'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-D10002' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-D10002'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-identity-dc-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-D10002' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-wsus-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M09010'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-wsus-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M09010' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-wsus-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-M09010'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-wsus-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-M09010' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-pta-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M10110'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-pta-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M10110' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-vm-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M28006'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-vm-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M28006' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-vm-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M28007'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-vm-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M28007' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-pbigw-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29003'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-pbigw-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29003' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-pbigw-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-M29003'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-pbigw-euw-tmp/providers/Microsoft.Compute/virtualMachines/EU-TMP-M29003' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/RG-MANAGEMENT-PBIGW-EUW-TST/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29004'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/RG-MANAGEMENT-PBIGW-EUW-TST/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29004' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/RG-MANAGEMENT-PBIGW-EUW-TMP/providers/Microsoft.Compute/virtualMachines/EU-TMP-M29004'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/RG-MANAGEMENT-PBIGW-EUW-TMP/providers/Microsoft.Compute/virtualMachines/EU-TMP-M29004' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-devopssha-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29100'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-devopssha-euw-tst/providers/Microsoft.Compute/virtualMachines/EU-AZT-M29100' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/avdc-euw-tst-gmcc-avd-test/providers/Microsoft.Compute/virtualMachines/EU-AZT-W27000'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/avdc-euw-tst-gmcc-avd-test/providers/Microsoft.Compute/virtualMachines/EU-AZT-W27000' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/avdc-euw-tst-gmcc-avd-test/providers/Microsoft.Compute/virtualMachines/EU-AZT-W27001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/avdc-euw-tst-gmcc-avd-test/providers/Microsoft.Compute/virtualMachines/EU-AZT-W27001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Converting parameter input on key 'imageIds'.
> VERBOSE: Parameter is an array. Still expected.
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2019datacenter-core-euw-tst-001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2019datacenter-core-euw-tst-001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2022datacenter-core-euw-tst-001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2022datacenter-core-euw-tst-001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2022datacenter-gui-euw-tst-001'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/rg-management-image-euw-tst/providers/Microsoft.Compute/galleries/gal_aib_euw_tst_001/images/gimg-aib-win-2022datacenter-gui-euw-tst-001' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> VERBOSE: Processing object '/subscriptions/xx/resourceGroups/cmp-euw-tst-gmcc-mgmt/providers/Microsoft.Compute/galleries/skgmcctstimagegallery01/images/win10-22h2-avd'. Full type name 'System.String'. Base type name 'System.String'
> VERBOSE: InputObject '/subscriptions/xx/resourceGroups/cmp-euw-tst-gmcc-mgmt/providers/Microsoft.Compute/galleries/skgmcctstimagegallery01/images/win10-22h2-avd' is of type PSObject: True. And of type System.String: True.
> VERBOSE: Looping through property 'Length', but we not really interested in this property on a string type..
> 
> Name                           Value
> ----                           -----
> excludedVMResourceIDs          {[value, System.Object[]]}
> imageIds                       {[value, System.Object[]]}
> 

If there's an easy way to stop PowerShell from wrapping that String in a PSObject then let me know, but I think I'm creating the object as I should be doing here..
Thanks in advance.

Best regards,
Sidney

### Issue script & Debug output

PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> $allowedWindowsVMImagesArrray.GetType()                 

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> $excludedVMsAllowedVMWindowsImagesPolicy.GetType()      

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> [hashtable]$DENonApprovedWinVMImageParameterObject = @{
>>
>>     'imageIds' = $AllowedWindowsVMImagesArrray
>>     'excludedVMResourceIDs' = $excludedVMsAllowedVMWindowsImagesPolicy
>> }
PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies>                                                         
PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies>     New-AzPolicyAssignment -DisplayName "DE-NonApprovedWinVMImage" -Name "DE-NonApprovedWinVMImage" -PolicyDefinition (Get-AzPolicyDefinition  -Id "/providers/Microsoft.Management/managementGroups/Core/providers/Microsoft.Authorization/policyDefinitions/Deny-VirtualMachine-NonApprovedWindowsImage") -PolicyParameterObject $DENonApprovedWinVMImageParameterObject @azPolicyAssignmentSplat -Debug
begin:New-AzPolicyAssignment( [DisplayName, DE-NonApprovedWinVMImage] [Name, DE-NonApprovedWinVMImage] [PolicyDefinition, Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.PolicyDefinition] [PolicyParameterObject, System.Collections.Hashtable] [Debug, True] [ErrorAction, Stop] [Scope, /providers/microsoft.management/managementgroups/Management] ) - (ParameterSet: ParameterObject)
Found and registered 3 dynamic parameters from 1 input parameters.
begin:New-AzPolicyAssignment( [DisplayName, DE-NonApprovedWinVMImage] [Name, DE-NonApprovedWinVMImage] [PolicyDefinition, Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.PolicyDefinition] [PolicyParameterObject, System.Collections.Hashtable] [Debug, True] [ErrorAction, Stop] [Scope, /providers/microsoft.management/managementgroups/Management] ) - (ParameterSet: ParameterObject)
process:New-AzPolicyAssignment( [DisplayName, DE-NonApprovedWinVMImage] [Name, DE-NonApprovedWinVMImage] [PolicyDefinition, Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.PolicyDefinition] [PolicyParameterObject, System.Collections.Hashtable] [Debug, True] [ErrorAction, Stop] [Scope, /providers/microsoft.management/managementgroups/Management] ) - (ParameterSet: ParameterObject)
-> Az.Policy.private\New-AzPolicyAssignment_CreateExpanded ( [DisplayName, DE-NonApprovedWinVMImage] [Name, DE-NonApprovedWinVMImage] [ParameterTable, System.Collections.Hashtable] [EnableSystemAssignedIdentity, False] [Debug, True] [ErrorAction, Stop] [Scope, /providers/microsoft.management/managementgroups/Management] [PolicyDefinitionId, /providers/Microsoft.Management/managementGroups/Core/providers/Microsoft.Authorization/policyDefinitions/Deny-VirtualMachine-NonApprovedWindowsImage] )
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing: 
DEBUG: CmdletProcessRecordStart: 

Confirm
Are you sure you want to perform this action?
Performing the operation "New-AzPolicyAssignment_CreateExpanded" on target "Call remote 'PolicyAssignmentsCreate' operation".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
DEBUG: CmdletGetPipeline: 
DEBUG: CmdletBeforeAPICall: 
DEBUG: URLCreated: //providers/microsoft.management/managementgroups/Management/providers/Microsoft.Authorization/policyAssignments/DE-NonApprovedWinVMImage?api-version=2023-04-01
DEBUG: RequestCreated: //providers/microsoft.management/managementgroups/Management/providers/Microsoft.Authorization/policyAssignments/DE-NonApprovedWinVMImage?api-version=2023-04-01
DEBUG: HeaderParametersAdded: 
DEBUG: BodyContentSet: 
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com//providers/microsoft.management/managementgroups/Management/providers/Microsoft.Authorization/policyAssignments/DE-NonApprovedWinVMImage?api-version=2023-04-01

Headers:
[Removed]

Body:
{
  "properties": {
    "displayName": "DE-NonApprovedWinVMImage",
    "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/Core/providers/Microsoft.Authorization/policyDefinitions/Deny-VirtualMachine-NonApprovedWindowsImage",
    "parameters": {
      "excludedVMResourceIDs": {
        "value": [
          {
            "Length": 147
          },
          {
            "Length": 147
          },
          {
            "Length": 147
          },
          {
            "Length": 147
          },
          {
            "Length": 151
          },
          {
            "Length": 151
          },
          {
            "Length": 139
          },
          {
            "Length": 138
          },
          {
            "Length": 138
          },
          {
            "Length": 152
          },
          {
            "Length": 152
          },
          {
            "Length": 152
          },
          {
            "Length": 152
          },
          {
            "Length": 145
          },
          {
            "Length": 151
          },
          {
            "Length": 151
          }
        ]
      },
      "imageIds": {
        "value": [
          {
            "Length": 204
          },
          {
            "Length": 204
          },
          {
            "Length": 203
          },
          {
            "Length": 172
          }
        ]
      }
    }
  }
}

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

Status Code:
BadRequest

Headers:
[Removed]

Body:
{
  "error": {
    "code": "InvalidPolicyParameters",
    "message": "A function or parameter in policy set or assignment 'DE-NonApprovedWinVMImage' associated with the policy definition 'Deny-VirtualMachine-NonApprovedWindowsImage' could not be validated. If using template functions, try following the tips in: https://aka.ms/policy-avoiding-template-failures. The inner exception 'Could not parse expression as array of strings: [\r\n  {\r\n    \"Length\": 147\r\n  },\r\n  {\r\n    \"Length\": 147\r\n  },\r\n  {\r\n    \"Length\": 147\r\n  },\r\n  {\r\n    \"Length\": 147\r\n  },\r\n  {\r\n    \"Length\": 151\r\n  },\r\n  {\r\n    \"Length\": 151\r\n  },\r\n  {\r\n    \"Length\": 139\r\n  },\r\n  {\r\n    \"Length\": 138\r\n  },\r\n  {\r\n    \"Length\": 138\r\n  },\r\n  {\r\n    \"Length\": 152\r\n  },\r\n  {\r\n    \"Length\": 152\r\n  },\r\n  {\r\n    \"Length\": 152\r\n  },\r\n  {\r\n    \"Length\": 152\r\n  },\r\n  {\r\n    \"Length\": 145\r\n  },\r\n  {\r\n    \"Length\": 151\r\n  },\r\n  {\r\n    \"Length\": 151\r\n  }\r\n]'."     
  }
}

DEBUG: ResponseCreated: 
DEBUG: BeforeResponseDispatch: 
DEBUG: CmdletProcessRecordEnd: 
New-AzPolicyAssignment_CreateExpanded: C:\Program Files\WindowsPowerShell\Modules\Az.Resources\7.3.0\Policy.Autorest\custom\New-AzPolicyAssignment.ps1:421:19
Line |
 421 |      $scriptCmd = {& $wrappedCmd @calledParameters}
     |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | A function or parameter in policy set or assignment 'DE-NonApprovedWinVMImage' associated with the policy definition 'Deny-VirtualMachine-NonApprovedWindowsImage' could not be validated. If using template functions, try following the tips in: https://aka.ms/policy-avoiding-template-failures. The inner exception 'Could not   
     | parse expression as array of strings: [   {     "Length": 147   },   {     "Length": 147   },   {     "Length": 147   },   {     "Length": 147   },   {     "Length": 151   },   {     "Length": 151   },   {     "Length": 139   },   {     "Length": 138   },   {     "Length": 138   },   {     "Length": 152   },   {    
     | "Length": 152   },   {     "Length": 152   },   {     "Length": 152   },   {     "Length": 145   },   {     "Length": 151   },   {     "Length": 151   } ]'.

### Environment data

PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> $PSVersionTable

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

### Module versions

PS C:\Users\a1-ligthsi\Documents\WindowsPowerShell\AzureRepos\LandingZones\AzurePolicies> Get-Module Az*                              

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     7.3.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}

### Error output

   HistoryId: 161

Message        : [InvalidPolicyParameters] : A function or parameter in policy set or assignment 'DE-NonApprovedWinVMImage' associated with the policy definition 'Deny-VirtualMachine-NonApprovedWindowsImage' could not be validated. If using template functions, try following the tips in: 
                 https://aka.ms/policy-avoiding-template-failures. The inner exception 'Could not parse expression as array of strings: [
                   {
                     "Length": 147
                   },
                   {
                     "Length": 147
                   },
                   {
                     "Length": 147
                   },
                   {
                     "Length": 147
                   },
                   {
                     "Length": 151
                   },
                   {
                     "Length": 151
                   },
                   {
                     "Length": 139
                   },
                   {
                     "Length": 138
                   },
                   {
                     "Length": 138
                   },
                   {
                     "Length": 152
                   },
                   {
                     "Length": 152
                   },
                   {
                     "Length": 152
                   },
                   {
                     "Length": 152
                   },
                   {
                     "Length": 145
                   },
                   {
                     "Length": 151
                   },
                   {
                     "Length": 151
                   }
                 ]'.
StackTrace     : 
Exception      : System.Exception
InvocationInfo : {New-AzPolicyAssignment_CreateExpanded}
Line           :     $scriptCmd = {& $wrappedCmd @calledParameters}

Position       : At C:\Program Files\WindowsPowerShell\Modules\Az.Resources\7.3.0\Policy.Autorest\custom\New-AzPolicyAssignment.ps1:421 char:19
                 +     $scriptCmd = {& $wrappedCmd @calledParameters}
                 +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 161
microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aperezcloud, @kenieva.

microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aperezcloud, @kenieva.