Running a whatif deployment (new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' -TemplateParameterFile .\environments\nonprod.bicepparam -whatif) using a bicep that has custom types included, turns the parameters to null instead of the referenced type.
Running the same command (az deployment group create -g 'rg-appgw-nonprod' -p .\environments\nonprod.bicepparam --what-if) with az cli works as intended.
Worth mentioning is that it is possible using the command "new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' -TemplateParameterFile .\environments\nonprod.bicepparam" to perform a successful deployment.
However, adding the -whatif causes the error.
Below is the debug output / generated parameters object from the different deployment methods.
The parameters which uses the custom types:
probes
requestRoutingRules
httpListeners
backendHttpSettingsCollections
backendAddressPools
frontEndPorts
Az PowerShell parameter object (generated from the az powershell command)
HistoryId: 12
RequestId :
Message :
InvalidTemplate - Long running operation failed with status 'Failed'. Additional Info:'Deployment template validation failed: 'One of template parameters has empty or invalid content.
Please see https://aka.ms/arm-syntax-parameters for usage details.'.'
ServerMessage :
ServerResponse :
RequestMessage :
InvocationInfo : {New-AzResourceGroupDeployment}
Line : new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' -TemplateParameterFile .\environments\nonprod.bicepparam -whatif
Position : At line:1 char:1
+ new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' - …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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()
HistoryId : 12
Description
Running a whatif deployment (new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' -TemplateParameterFile .\environments\nonprod.bicepparam -whatif) using a bicep that has custom types included, turns the parameters to null instead of the referenced type. Running the same command (az deployment group create -g 'rg-appgw-nonprod' -p .\environments\nonprod.bicepparam --what-if) with az cli works as intended.
Worth mentioning is that it is possible using the command "new-azresourcegroupdeployment -resourcegroupname 'rg-appgw-nonprod' -TemplateParameterFile .\environments\nonprod.bicepparam" to perform a successful deployment. However, adding the -whatif causes the error.
Below is the debug output / generated parameters object from the different deployment methods.
The parameters which uses the custom types:
Az PowerShell parameter object (generated from the az powershell command)
Az Cli Parameters object (generated from the az cli command):
Issue script & Debug output
Environment data
Module versions
Error output