`azurerm_function_app_function` resource deleting itself after creation
Is there an existing issue for this?
- [X] I have searched the existing issues
Community Note
- Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
1.2.6
AzureRM Provider Version
3.17.0
Affected Resource(s)/Data Source(s)
azurerm_function_app_function
Terraform Configuration Files
resource "azurerm_function_app_function" "defer_function" {
name = "defer"
function_app_id = azurerm_linux_function_app.pyperchan_function_app.id
config_json = jsonencode(
{
"bindings" = [
{
authLevel = "anonymous"
direction = "in"
methods = [
"post"
]
name = "req"
type = "httpTrigger"
},
{
direction = "out"
name = "$return"
type = "http"
},
]
}
)
file {
name = "__init__.py"
content = <<EOT
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
EOT
}
language = "Python"
}
Debug Output/Panic Output
https://gist.github.com/SocMinarch/0ae91588c57a71c64a6a6e0b86b4d3df
Expected Behaviour
The Azure Function is deployed
Actual Behaviour
The Azure Function is deployed, but trying to access it returns a HTTP 404 error. After a few seconds the Function disappears from the Azure Portal. If Terraform tries to remove the Function, this fails as Azure returns a HTTP 404 error. The entire Function App then has to be destroyed through the Azure Portal.
Code does not appear to be uploaded to the linked Storage Account.
Steps to Reproduce
terraform apply- Find the Function App in the Azure Portal
- Refresh the Functions list after ~1 minute
Important Factoids
No response
References
No response
Issue still occurs if no file block is provided to azurerm_function_app_function
Similar Behaviour with EventGridTrigger type
Occurs with language set to Javascript too
I am having a similar issue as OP. Also using Python, but I am using a blobTrigger. The Terraform Apply runs fine, the function will be present for a few seconds and then disappear. I am wondering if this is an issue with the underlying Azure API call.
Terraform code:
resource "azurerm_linux_function_app" "main" {
name = "tf-linux-app"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
service_plan_id = azurerm_service_plan.main.id
storage_account_name = azurerm_storage_account.main.name
storage_account_access_key = azurerm_storage_account.main.primary_access_key
site_config {
app_scale_limit = 200
elastic_instance_minimum = 0
application_stack {
python_version = "3.9"
}
}
app_settings = {
"${azurerm_storage_account.main.name}_STORAGE" = azurerm_storage_account.main.primary_connection_string
}
client_certificate_mode = "Required"
identity {
type = "SystemAssigned"
}
}
resource "azurerm_function_app_function" "main" {
name = "tf-BlobTrigger"
function_app_id = azurerm_linux_function_app.main.id
language = "Python"
file {
name = "__init__.py"
content = file("__init__.py")
}
test_data = "${azurerm_storage_container.container1.name}/{name}"
config_json = jsonencode({
"scriptFile" : "__init__.py",
"bindings" : [
{
"name" : "myblob",
"type" : "blobTrigger",
"direction" : "in",
"path" : "${azurerm_storage_container.container1.name}/{name}",
"connection" : "${azurerm_storage_container.container1.name}_STORAGE"
}
]
})
}
As far as the Python script, I'm literally just trying the demo found here that Azure provides.
__init__.py:
import logging
import azure.functions as func
def main(myblob: func.InputStream):
logging.info('Python Blob trigger function processed %s', myblob.name)
I have been able to deploy a C# function to a Windows app without an issue. Not sure whether the issue now is with a Python function or a Linux app.
I'm also having the same issue, as my Function App keeps deleting it's Function after a few minutes. So I looked at the Activity Logs in my Function App and saw errors regarding List Web Apps Functions Keys, which was successful in my windows Function Apps version that worked. Still investigating...
Having the same issue with Node and Powershell functions.