我如何使用 terraform 从远程 git 以 azure 部署函数应用程序?

How can i deploy an function-app in azure from a remote git using terraform?

当 运行 我的 terraform 部署时,我想从远程 git 服务器拉取一个函数应用程序。 在同一个 Terraform 模板中,我毫无问题地从私有注册表部署了 docker 图像。我只是找不到如何从远程 git 服务器部署函数应用程序。

实际上,Azure 函数没有 属性 来设置 Terraform 中的 GitHub 存储库。您可以在 Azure Function 中看到所有属性支持。

但您可以在 Terraform 中使用 Azure CLI 和供应器 "local-exec"。查看 Terraform module for Azure FunctionApp and use the Azure CLI command az functionapp deployment source config 中的步骤,而不是代码中的 CLI 命令。然后供应商 "local-exec" 将如下所示:

provisioner "local-exec" {
    command = "${var.git_enabled ? join("", list("az functionapp deployment source config --ids ", azurerm_function_app.funcapp.id), " --repo-url github_URI", " --branch master --manual-integration") : "true"}"
  }