【发布时间】:2019-10-20 17:05:35
【问题描述】:
我在本地使用 Visual Studio 创建了一个 azure 函数。我正在尝试使用 terraform 部署 azure 函数,但它抛出错误
我正在尝试的代码如下所示:
resource "azurerm_function_app" "testDeployTF" {
name = "testDeployADddecendant"
location = "${azurerm_resource_group.rg-testDeployTF.location}"
resource_group_name = "${azurerm_resource_group.rg-testDeployTF.name}"
app_service_plan_id = "${azurerm_app_service_plan.sp-testDeployTF.id}"
storage_connection_string = "DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxxxxxxxxx;EndpointSuffix=core.windows.net"
app_settings {
HASH = "${base64sha256(file("FunctionApp1.zip"))}"
WEBSITE_USE_ZIP = "https://${decendant.sa-testDeployTF.name}.blob.core.windows.net/${azurerm_storage_container.sc-testDeployTF.name}/${azurerm_storage_blob.sb-testDeployTF.name}${data.azurerm_storage_account_sas.sas-testDeployTF.sas}"
}
}
如果我删除 app_setting 代码会创建一个新的空函数,但我想要的是我需要一个新函数,其中包含我在本地拥有的代码。
当我使用 app_seettings 时,上面的代码会引发以下错误:
错误:不支持的块类型
在 terraformscript.tf 第 78 行,在资源“azurerm_function_app”“testDeployTF”中: 78:应用程序设置{
此处不应出现“app_settings”类型的块。
【问题讨论】:
-
我需要将 app_settings 放入 variable.tf 吗?
-
我不认为你可以使用 terraform 一步创建包含代码的函数。
-
@CharlesXu 那你怎么办。基本上我有一个通过 Visual Studio 创建的天蓝色函数,我希望使用 terraform 将此函数部署到天蓝色门户
-
当你使用visual studio时,它会使用azure-function-core-tool等扩展为你复制代码。而 terraform 正好可以为你创建功能。您需要自己将代码复制到函数中。
-
@CharlesXu 我希望这是自动化的,那么粘贴代码的最简单方法是什么?我在 blob 中上传了代码。
标签: azure azure-functions terraform terraform-provider-azure