Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.21k stars 745 forks source link

devOps bicep Vm deployment fails with the ERROR: unrecognized arguments #10818

Open gihan99 opened 1 year ago

gihan99 commented 1 year ago

Keep getting the error below on the DevOps bicep release pipeline while using the bicep file. Error: Error: Command failed: az bicep build --file D:\a\r1\a_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.bicep ERROR: unrecognized arguments: xxxxxxxxxxxxxxxxxxxxxxx.bicep

Steps Tried:

  1. Tried to deploy the bicep file using VScode and it deploys fine without any errors.
  2. Tested changing the hosted agent version to Ubntu Latest and windows server 2022, but kept getting the same error.
  3. Used "az bicep build --file xxxx.bicep" to build the JSON file and used that on the release pipeline instead of the bicep file and it works fine.

What I have on the release pipeline is an ARM task and I have selected the xxxx.bicep file for the template file, parameters.json file as the Parameters files and I have an override parameter to set a value from a pipeline variable. Below is the yml output of the task I have on the release pipeline

#Your build pipeline references a secret variable named ‘storageAccountSASToken’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'ARM Template deployment: Resource Group scope'
  inputs:
    azureResourceManagerConnection: 'xxxxxxx - Test'
    subscriptionId: 'xxxxxxx'
    resourceGroupName: 'remotedesktop'
    location: 'West Europe'
    csmFile: '$(System.DefaultWorkingDirectory)/_xxxxxxxxxxxxxxxxxxxx.json'
    csmParametersFile: '$(System.DefaultWorkingDirectory)/_XXXXXXXXXXXXXXXXXXXXXX.parameters.json'
    overrideParameters: '-dscArtifactsLocationSasToken "$(storageAccountSASToken)"'
    deploymentName: 'EUW-DevOps'
brwilkinson commented 1 year ago

@gihan99 you can check this doc for storing a secret in a variable, then consuming that variable.

gihan99 commented 1 year ago

@brwilkinson I tried the suggested option to have the secrets linked to the variable group and I got the same error mentioned above. I moved the source files to a new project on Azure DevOps and created a release pipeline. it worked, so clearly some thing is messed up on the old project, what could it be ?

brwilkinson commented 1 year ago

Add a powershell task and list the environment variables to troubleshoot.

dir env: