Skip to content

Az PowerShell Bicepparam deployments / WhatIf does not work if filename contains brackets. #29150

@bjompen

Description

@bjompen

Description

When deploying or getting WhatIf results using Get-AzResourceGroupDeploymentWhatIfResult or New-AzResourceGroupDeployment, if using a bicepparam file with brackets - [ ] - in filename, the deployment fails with Invalid Bicepparam file path..
This is only the case in param files, templates work.

Repro steps:

Create a bicep file with simple contents:

param inValue string = 'in'
output outValue string = inValue

Save it as filename with .bicep extension.

Create a bicepparam file to match

using 'test[Bicep].bicep'
param inValue = 'whatever'

Doing a WhatIf deploy of only bicep file works, but using the bicepparam file fails.

Image

Escaping the brackets or not, trying the solution from the similar issue with blobs it all has the same result. Also verified on PowerShell on Windows and Linux machines.

Deploys with az cli works fine.

The obvious solution and general recommendation is always "Don't use weird characters in file names", but since brackets are valid file name characters and do work with the bicep file, I do think they should work with bicepparam files as well.

(Oh, and just to be clear - I have not tested this with ARM json param files, and do not know they behaviour there.)

Issue script & Debug output

> Get-AzResourceGroupDeploymentWhatIfResult -Name 'test' -ResourceGroupName RG -TemplateFile '.\test`[Bicep`].bicep' -TemplateParameterFile '.\test`[Bicep`].bicepparam'

DEBUG: 09:27:10 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 09:27:10 - GetAzureResourceGroupDeploymentWhatIfResultCmdlet begin processing with ParameterSet 'ByTemplateFileAndParameterFile'.
DEBUG: 09:27:10 - using account id 'nope, not sharing this'...
DEBUG: 09:27:10 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Resources], Cmdlet = [Get-AzResourceGroupDeploymentWhatIfResult]. Returning default value [True].

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
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     5.3.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     9.0.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}

Error output

HistoryId: 46

Message        : Invalid Bicepparam file path.
StackTrace     :    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.BeginProcessing()
                    at System.Management.Automation.Cmdlet.DoBeginProcessing()
                    at System.Management.Automation.CommandProcessorBase.DoBegin()
Exception      : Microsoft.Azure.Commands.Common.Exceptions.AzPSArgumentException
InvocationInfo : {Get-AzResourceGroupDeploymentWhatIfResult}
Line           : Get-AzResourceGroupDeploymentWhatIfResult -Name 'test' -ResourceGroupName RG -TemplateFile '.\test`[Bicep`].bicep' -TemplateParameterFile '.\test`[Bicep`].bicepparam'
Position       : At line:1 char:1
                 + Get-AzResourceGroupDeploymentWhatIfResult -Name 'test' -ResourceGroup 
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 46

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedneeds-triageThis is a new issue that needs to be triaged to the appropriate team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions