#Bicep deployment with bicepparam file fails in Devops

1 messages · Page 1 of 1 (latest)

meager fulcrum
#

I'm trying to replace my json param files with new bicepparam files, but running the script in DevOps, It seems like a ' is added to the beginning of the params, making deployment fail with the following message:
error: unrecognized template parameter 'using '../main.bicep'2023-06-15T13:20:37.9254375Z 2023-06-15T13:20:37.9254901Z param env '. Allowed parameters: env, xxx and xxx.
The same command works locally on my mac and i just tried it on a windows VM, and it works there as well.

The command I'm running throught the AZ CLI v2 task in Azure Dev Ops from a .sh file is:
az deployment group create --resource-group rg-xxx-$ENV --name xxxx-infra-$BUILD -f _xxxx-infra/main.bicep --parameters @_xxxx-infra/parameters/$ENV.bicepparam

$ENV=dev and $BUILD should not be important.

Does anyone have any ideas on why this is hapening or what is hapening?

#

The param file looks like this(removed some params that revealed what project this is):
`using '../main.bicep'

param env = 'dev'
param ipPlan = {
VirtualNetwork: [
'10.191.144.0/24'
]
ApplicationGateway: '10.191.144.0/27'
AppIn: '10.191.144.128/29'
AppOut: '10.191.144.32/27'
KeyVault: '10.191.144.96/29'
PostgresServer: '10.191.144.144/28'
CosmosAccount: '10.191.144.112/29'
StorageAccount: '10.191.144.104/29'
ServiceBus: '10.191.144.120/29'
VirtualMachineScaleSet: '10.191.144.160/27'
VirtualNetworkGateway: '10.191.144.192/27'
VPNClientIpRange: '10.191.145.192/27'
}
param VirtualNetworkGatewayEnabled = false
`

hardy ravine
#

Won't help you but everything looks fine at first glance

#

Do you have anything between the using and the param env in the real file ?

open sonnet
#

is your azcli and bicep versions up to date?

hardy ravine
#

Ok. Then I'd check what ktremain said

meager fulcrum
# open sonnet is your azcli and bicep versions up to date?

Yes, the scripts are running on the windows-2022 hosted agents.

And i tried running the script with these commands first:
az version az upgrade az bicep version az bicep upgrade

But that had no effect:

`[command]/usr/bin/bash /home/vsts/work/r1/a/_xxxx-infra/deploymentscripts/deploy.sh
{
"azure-cli": "2.49.0",
"azure-cli-core": "2.49.0",
"azure-cli-telemetry": "1.0.8",
"extensions": {
"azure-devops": "0.26.0"
}
}
WARNING: This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
WARNING: You already have the latest azure-cli version: 2.49.0
WARNING: Upgrading extensions
WARNING: Checking update for azure-devops
WARNING: Latest version of 'azure-devops' is already installed.

Use --debug for more information
WARNING: Upgrade finished.You can enable auto-upgrade with 'az config set auto-upgrade.enable=yes'. More details in https://docs.microsoft.com/cli/azure/update-azure-cli#automatic-update
Bicep CLI version 0.17.1 (d423d61882)

WARNING: The configuration value of bicep.use_binary_from_path has been set to 'false'.
Installing Bicep CLI v0.18.4...
Successfully installed Bicep CLI to "/home/vsts/work/_temp/.azclitask/bin/bicep".
ERROR: unrecognized template parameter 'using '../main.bicep'

param env '. Allowed parameters: VirtualNetworkGatewayEnabled, env, ipPlan, location, postgresStorageSize, scaleSetSKU, xxxxx, xxxxx, xxxxx.
##[error]Script failed with exit code: 1`

hardy ravine
#

That's really weird

#

My next guess is that the syntax used for the az command is the one for json parameters and it may be a different one for bicepparam.
But hard to find documentation

meager fulcrum
#

Yes, very weird. I have tried this az command both locally and on a windows VM(to eliminate windows related issues). And it works without problem there.

#

My thinking is that it might be related to artifacts in devops, but not sure how they would behave differently than local files🤔

hardy ravine
#

Quick thought, is it GA ?

#

Or do you still need to add the experimentalFeaturesEnabled flag ?

#

Also, try removing the @ in front of the file's name

#

I found this example online :

az deployment group create  \
-p .\main.bicepparam \
-f .\main.bicep \
-g "rg-foo"
open sonnet
#

its ga if you are on v18

#

actually, is it even supported (yet) to have the params file in a different folder to the parent?

#

what happens if you move the bicepparams to the same folder, and change it to "using main.bicep" ?

hardy ravine
#

It's supposed to be supported from what I read

#

As of now, my main guess is the @ is not needed and makes the exectuable think it's a Json file

meager fulcrum
#

Thanks for the feedback, i had to revert the changes, in order to progress with other changes. But i will make the changes in another branch and try again when i have time 🙂

My guess is that the @ is the problem, can't remember why i added it initially, but i will try without it.

hardy ravine
#

Keep us updated 🙂

meager fulcrum
#

The @ was indeed the problem, quite obvious in hindsight. 🙃 Thanks for the help! 😀

hardy ravine
#

Nice 🙂 Thanks for confirming