I'm trying to deploy an azure function via terraform and everytime I update code & create a new zip file and run terraform apply locally, it doesn't register the change and shows nothing to update. I thought using the hash() function inside the appsettings of the function app like below, should have been enough to detect changes to the zip folder and force the redeployment. What changes can I make to allow force update everytime the zip file changes. Also is there a way to allow force deployment of a resource regardless of any changes in terraform state?
resource "azurerm_storage_blob" "app" {
name = "${var.storageblobname}"
storage_account_name = "${azurerm_storage_account.app.name}"
storage_container_name = "${azurerm_storage_container.app.name}"
type = "Block"
source = "./../functionapp.zip"
}
resource "azurerm_function_app" "app" {
name = "${var.appname}"
location = "${azurerm_resource_group.app.location}"
resource_group_name = "${azurerm_resource_group.app.name}"
app_service_plan_id = "${azurerm_app_service_plan.app.id}"
storage_connection_string = "${azurerm_storage_account.app.primary_connection_string}"
identity {
type = "SystemAssigned"
}
version = "~3"
app_settings = "${merge(var.appsettings,
map("APPINSIGHTS_INSTRUMENTATIONKEY", "${azurerm_application_insights.app.instrumentation_key}",
"FUNCTIONS_WORKER_RUNTIME", "powershell",
"FUNCTION_APP_EDIT_MODE", "readonly",
"https_only", true,
"HASH", "${filebase64sha256("./../functionapp.zip")}",
"WEBSITE_RUN_FROM_PACKAGE", "https://${azurerm_storage_account.app.name}.blob.core.windows.net/${azurerm_storage_container.app.name}/${azurerm_storage_blob.app.name}${data.azurerm_storage_account_sas.app.sas}"
))}"
}