简体   繁体   English

在 azure 函数中运行 terrform powershell

[英]Run terrform in azure functions powershell

We are developing an azure function which should run terraform cmdlets like init, plan and apply.我们正在开发一个 azure function 应该运行 terraform cmdlet,如 init、plan 和 apply。

when we run above commands in powershell, we are getting below error.当我们在 powershell 中运行上述命令时,我们遇到了以下错误。

Error checking configuration: <nil>: Failed to read module directory; Module directory C:\home\site\wwwroot\databricks-user-sync-modules does not exist or cannot be read

My run.ps1 file includes below sinppet我的 run.ps1 文件包括以下 sinppet

write-output (terraform --version)
Write-Output ((Get-ChildItem).Name)
Get-Content -Path main.tf
write-output (terraform init)
terraform plan -var-file dev.tfvars

How to run terraform in azure functions.如何在 azure 函数中运行 terraform。

The error message you are receiving may or may not be related to your attempt to use terraform in Azure Functions.您收到的错误消息可能与您尝试在 Azure 函数中使用 terraform 相关,也可能不相关。

I'd initially ask whether Azure Functions is the ideal solution to the problem you're trying to solve?我最初会问 Azure Functions 是否是您要解决的问题的理想解决方案?

Based on the fact that the functions runtime doesn't include the terraform binary in order to run tf cli commands.基于函数运行时不包含 terraform 二进制文件以运行 tf cli 命令的事实。 You may have more success using Azure Devops pipelines or Github Actions to deploy your terraform code.使用 Azure Devops 管道或 Github 操作来部署 terraform 代码,您可能会取得更大的成功。

Both AzDo and Github can trigger CI/CD operations via a webhook. AzDo 和 Github 都可以通过 webhook 触发 CI/CD 操作。

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatch https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatch

and

https://docs.microsoft.com/en-us/azure/devops/release-notes/2020/pipelines/sprint-172-update https://docs.microsoft.com/en-us/azure/devops/release-notes/2020/pipelines/sprint-172-update

Unless I am missing something obvious, you may have to provide more context around why you're using Azure Functions for this scenario除非我遗漏了一些明显的东西,否则您可能必须提供更多背景信息来说明您为何在此场景中使用 Azure 函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM