Coder Perfect

Can Azure Bicep Modules be referenced from a different repo?

Problem

I’m more comfortable with Terraform, where I can perform operations such as:

module "storagemod" {
  source = "git::https://MyProj@dev.azure.com/MyProj/Dataplatform/_git/myrepo//storage-account?ref=v0.2.0"
  rg_name = "MyRG"
  resource_name = "mynewdatalake"
  .
  .
  .
}

where the above-mentioned source is a distinct Terraform module repository that I’m using to construct resources.

The repository is a private Azure repository (on Azure DevOps) that I can access thanks to git credentials I established in a previous step of the pipeline:

steps:
  - task: PowerShell@2
    inputs:
      targetType: inline
      script: 'git config --global http.extraheader "AUTHORIZATION: bearer ${Env:SYSTEM_ACCESSTOKEN}"'
    displayName: 'Setting Git Authentication header'
    env:
      SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Is there a way I could accomplish something similar with Azure Bicep? We’re attempting to transfer to Bicep.

I can do the same authentication of the Git headers, of course, but how can I handle the module?

I could perform the following if it was local on the same repo:

module storagemod './storage/datalake.bicep' = {
  name: 'createDataLakeAndContainers'
  params: {
    .
    .
    .
  }
}

Is it possible for me to do something similar?

module storagemod 'git::https://MyProj@dev.azure.com/MyProj/Dataplatform/_git/myrepo//storage-account?ref=v0.2.0' = {
  name: 'createDataLakeAndContainers'
  params: {
    .
    .
    .
  }
}

I couldn’t get that to work, but I was hoping that the capability is there and I just had the syntax wrong. I could not find any documentation on it.

Asked by Mike Williamson

Solution #1

In Biceps, this is not possible (yet).

This issue is addressed in two open issues on bicep’s github:

For the time being, the only options are to use git submodules or specialized solutions to retain “remote” bicep files.

Answered by Miq

Post is based on https://stackoverflow.com/questions/67439742/azure-bicep-modules-can-modules-be-referenced-from-a-separate-repo