Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Bicep Modules: Can modules be referenced from a separate repo?

Functioning Code Using Terraform

I am more familiar with Terraform, where I can do something like:

module "storagemod" {
  source = "git::https://[email protected]/MyProj/Dataplatform/_git/myrepo//storage-account?ref=v0.2.0"
  rg_name = "MyRG"
  resource_name = "mynewdatalake"
  .
  .
  .
}

where the source referenced above is a different repository of Terraform modules that I am referencing to create resources.

The repository is a private Azure repository (on Azure DevOps) that I am able to access because I have already established git credentials 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)

How to Do This in Bicep?

How could I do something similar using Azure Bicep? We are trying to move over to Bicep.

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

Local

If it were local on the same repo, I could do:

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

Separate Repo

Can I do something like this?

module storagemod 'git::https://[email protected]/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.

like image 481
Mike Williamson Avatar asked Oct 23 '25 17:10

Mike Williamson


1 Answers

This is not possible in Bicep (yet).

There are two open issues in bicep's github that addresses this issue:

  • https://github.com/Azure/bicep/issues/660
  • https://github.com/Azure/bicep/issues/2128

For now only way is to use either git submodules or maintain "remote" bicep files using some custom solutions.

like image 109
Miq Avatar answered Oct 26 '25 07:10

Miq