微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

文件上传的Terraform Azure功能应用

如何解决文件上传的Terraform Azure功能应用

我正在尝试通过从本地文件系统上载zip文件来创建Java Azure函数应用程序。下面是代码。从Windows 10系统运行时,它按预期工作。从ubuntu系统运行时,相同的代码似乎不起作用,没有错误,但function app在azure门户上没有任何功能。 Windows和ubuntu上的terraform版本相同(terraform v0.12.28)。但是它似乎在Ubuntu上不起作用。以下是Azure门户功能应用程序上的错误消息

enter image description here

var.functionapp =“ func_java.zip”,zip文件位于main.tf的同一文件夹中

├── main.tf
├── tran_fun.zip
└── variables.tf


resource "azurerm_storage_blob" "appcode" {
    name = "functionapp.zip"
    storage_account_name = "${azurerm_storage_account.storage_account.name}"
    storage_container_name = "${azurerm_storage_container.storage_container_deployement.name}"
    type = "Block"
    source = "${var.functionapp}"
}


# // /***********************function app **********************************/
resource "azurerm_app_service_plan" "spp_service_plan" {
  name                = "${local.app_serv_plan_name}"
  resource_group_name = azurerm_resource_group.rg_creation.name
  location            = azurerm_resource_group.rg_creation.location
  kind                = "FunctionApp"

  sku {
    tier = "Dynamic"
    size = "Y1"
  }
}

resource "azurerm_function_app" "function_app" {
  name                      =  "${local.app_serv_name}" 
  resource_group_name = azurerm_resource_group.rg_creation.name
  location            = azurerm_resource_group.rg_creation.location
  app_service_plan_id       = azurerm_app_service_plan.spp_service_plan.id
  storage_connection_string = azurerm_storage_account.storage_account.primary_connection_string
  app_settings = {
    FUNCTIONS_WORKER_RUNTIME = "java"
    FUNCTIONS_EXTENSION_VERSION = "~3"
    APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.app_insights.instrumentation_key
    APPLICATIONINSIGHTS_CONNECTION_STRING = "InstrumentationKey=${azurerm_application_insights.app_insights.instrumentation_key}"
    HANA_CREDENTIALS = var.hanaCredentials
    TENANT_ID = var.cptenantId
    HASH = "${filebase64sha256("${var.functionapp}")}"
    WEBSITE_RUN_FROM_PACKAGE = "https://${azurerm_storage_account.storage_account.name}.blob.core.windows.net/${azurerm_storage_container.storage_container_deployement.name}/${azurerm_storage_blob.appcode.name}${data.azurerm_storage_account_sas.sas.sas}"
   
 }
}

以下是来自功能应用程序控制台的错误消息

enter image description here

解决方法

如果.zip文件位于main.tf的同一文件夹中,则可以这样定义变量。

variable "functionapp" {
    type = "string"
    default = "./func_java.zip"
}

它对我有利。

enter image description here

有关更多详细信息,您可以阅读this blog

,

问题出在zip文件。从Windows中移出时Zip文件已损坏

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。