I’m running a Azure Devops AzureCLI@2
step that compiles my main.bicep
file before I put it in an artifact to deploy that infrastructure later.
I’m getting an error that the defined modules in my bicepConfig.json
file are not being found.
Here is my pipeline YAML
- job: publish_bicep
displayName: Publish Bicep Template
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
- task: AzureCLI@2
name: validate_bicep
displayName: Validate Bicep
inputs:
azureSubscription: ${{ parameters.subscriptionsId }}
scriptType: pscore
scriptLocation: inlineScript
powerShellErrorActionPreference: stop
failOnStandardError: false
inlineScript: |
ls $(Build.SourcesDirectory)/environment
az bicep build --file $(Build.SourcesDirectory)/environment/main.bicep
- task: CopyFiles@2
displayName: Copying Bicep Templates
inputs:
SourceFolder: $(Build.SourcesDirectory)
Contents: |
environment/*.bicep
environment/*.json
TargetFolder: $(Build.ArtifactStagingDirectory)
- publish: $(Build.ArtifactStagingDirectory)
artifact: bicepTemplates
And here are the errors I’m getting
/usr/bin/az account set --subscription REMOVED
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/home/vsts/work/_temp/azureclitaskscript1703777321399.ps1'
bicepConfig.json
main.bicep
bicep.cert.parameters.json
bicep.prod.parameters.json
bicep.test.parameters.json
ERROR: /home/vsts/work/1/s/environment/main.bicep(20,17) : Error BCP212: The Template Spec module alias name "myrepo" does not exist in the built-in Bicep configuration.
/home/vsts/work/1/s/environment/main.bicep(48,28) : Error BCP212: The Template Spec module alias name "wegmans" does not exist in the built-in Bicep configuration.
2
Answers
Fixed this by changing
ubuntu-latest
towindows-latest
.I suspect it might have something to do with the weird casing I used when naming the file (bicepConfig.json instead of bicepconfig.json) that Ubuntu can't handle, and Azure DevOps won't let me change it now that the camel casing is checked in.
Either way, changing the
vmImage
fixed this for me.I have just copy and paste your code and test at my side, remain the vmImage "ubuntu-latest", it works well.