Azure Bicep模块:可以从单独的回购中引用模块吗



使用Terraform函数化代码

我更熟悉Terraform,在那里我可以做一些类似的事情:

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"
.
.
.
}

其中上面引用的source是Terraform模块的不同存储库,我正在引用它来创建资源。

该存储库是一个私有Azure存储库(在Azure DevOps上(,我可以访问它,因为我已经在管道的前一步中建立了git凭据:

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)

如何在Bicep中做到这一点

我如何使用Azure Bicep做类似的事情?我们正试图转移到Bicep。

当然,我可以对Git头进行同样的身份验证,但我如何处理模块呢?

本地

如果它是本地的同一回购,我可以做:

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

单独回购

我能做这样的事吗?

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

我没能做到这一点,但我希望有这种能力,但我只是语法错误。我在上面找不到任何文件。

这在Bicep中是不可能的。

二头肌的github中有两个悬而未决的问题可以解决这个问题:

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

目前唯一的方法是使用git子模块或维护";远程";使用一些自定义解决方案的二头肌文件。

最新更新