-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.
Description
Getting the above error when running the deploy from PowerShell 7.2.0 preview 5.
PowerShell 7.1.3 works as expected.
- Installed PowerShell 7.2.0 preview 5
- Logged into Azure
- Selected my subscription.
- Tried to deploy the new Azure Policy Definition.
New-AzPolicyDefinition -Name "allowed-locations3" `
-DisplayName "Allowed locations3" `
-Policy 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.rules.json' `
-Parameter 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.parameters.json' `
-Mode IndexedExpected behavior
~\Desktop > New-AzPolicyDefinition -Name "allowed-locations3" `
-DisplayName "Allowed locations3" `
-Policy 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.rules.json' `
-Parameter 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.parameters.json' `
-Mode Indexed
Name : allowed-locations3
ResourceId : /subscriptions/XXXXXX-XXXX-XXXX-XXXX-XXXXXX/providers/Microsoft.Authorization/policyDefinitions/allowed-locations3
ResourceName : allowed-locations3
ResourceType : Microsoft.Authorization/policyDefinitions
SubscriptionId : XXXXXX-XXXX-XXXX-XXXX-XXXXXX
Properties : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicyDefinitionProperties
PolicyDefinitionId : /subscriptions/XXXXXX-XXXX-XXXX-XXXX-XXXXXX/providers/Microsoft.Authorization/policyDefinitions/allowed-locations3
Actual behavior
C:\Program Files\PowerShell\7-preview> New-AzPolicyDefinition -Name "allowed-locations3" `
>> -DisplayName "Allowed locations3" `
>> -Policy 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.rules.json' `
>> -Parameter 'https://raw.githubusercontent.com/Azure/azure-policy/master/samples/built-in-policy/allowed-locations/azurepolicy.parameters.json' `
>> -Mode Indexed
New-AzPolicyDefinition: Length cannot be less than zero. (Parameter 'length')
C:\Program Files\PowerShell\7-preview> Get-Error
Exception :
Type : System.ArgumentOutOfRangeException
Message : Length cannot be less than zero. (Parameter 'length')
ParamName : length
TargetSite :
Name : HandleException
DeclaringType : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase
MemberType : Method
Module : Microsoft.Azure.PowerShell.Cmdlets.ResourceManager.dll
StackTrace :
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Source : Microsoft.Azure.PowerShell.Cmdlets.ResourceManager
HResult : -2146233086
CategoryInfo : CloseError: (:) [New-AzPolicyDefinition], ArgumentOutOfRangeException
FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzurePolicyDefinitionCmdlet
InvocationInfo :
MyCommand : New-AzPolicyDefinition
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 5
Line : New-AzPolicyDefinition -Name "allowed-locations3" `
PositionMessage : At line:1 char:1
+ New-AzPolicyDefinition -Name "allowed-locations3" `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : New-AzPolicyDefinition
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Environment data
Name Value
---- -----
PSVersion 7.2.0-preview.5
PSEdition Core
GitCommitId 7.2.0-preview.5
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
StefanIvemo
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.