I am using the import functionality in a bicep parameter file (bicepparam).
This works with the azure cli, but fails with the powershell module with the follow error:
Error BCP337: This declaration type is not valid for a Bicep
Parameters file. Specify a “using” or “param” declaration.
I am using Bicep CLI version 0.28.1, and version 12.0.0 of the Az powershell module.
I enable user defined funcitons with this bicepconfig.json file:
{
"experimentalFeaturesEnabled": {
"compileTimeImports": true,
"userDefinedFunctions": true
}
}
I add an export function in a cfg.bicep file:
@export()
func testFunction(x string) string => x
I import this in a test.bicepparam file
using 'test.bicep'
import * as vars from 'cfg.bicep'
param theVal = vars.testFunction('A Test String')
And this is my bicep file (test.bicep):
param theVal string
output Value string = theVal
I use this azure cli command:
az deployment group create –name ‘aaaaa’ –resource-group
MyResourceGroup –parameters $paramFile
This works, and I see the parameter named theVal has the correct string from the parameter file:
This fails when I use the powershell module with the same inputs. Here is the command:
New-AzResourceGroupDeployment -ResourceGroupName MyresourceGroup -Name 'aaaaa' -TemplateParameterFile $paramFile
I get the error at the beginning of this question: This declaration type is not valid for a Bicep Parameters file. Specify a “using” or “param” declaration.