CodexBloom - Programming Q&A Platform

Terraform: scenarios Deploying Azure Functions with Managed Identity and Custom Settings

๐Ÿ‘€ Views: 0 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-06-12
terraform azure functions hcl

I'm getting frustrated with I'm trying to deploy an Azure Function using Terraform, and I'm running into issues when I attempt to assign a managed identity to the function app... I set up the resource block for the function app and specified the identity, but I get the following behavior: ``` behavior: creating Function App 'my-function-app': behavior in function app deployment: The identity is invalid. ``` I've defined the function app like this: ```hcl resource "azurerm_function_app" "example" { name = "my-function-app" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name app_service_plan_id = azurerm_app_service_plan.example.id storage_account_name = azurerm_storage_account.example.name storage_account_access_key = azurerm_storage_account.example.primary_access_key os_type = "linux" version = "~3" identity { type = "SystemAssigned" } } ``` Iโ€™ve also tried explicitly specifying the identity configuration using the `azurerm_identity` resource, but that led to a different behavior: ``` behavior: "identity": "The identity must be assigned to a resource before it can be used." ``` I am using Terraform version 1.0.0 and the Azure provider version 2.56.0. I ensured that the resource group and storage account are created successfully before this function app resource is applied, but I canโ€™t seem to get past the identity assignment. Could anyone provide insights into what I might be missing? Is there a specific order of resource creation I need to follow, or any other configuration detail thatโ€™s required for using managed identities with Azure Functions? Any help would be greatly appreciated! Any help would be greatly appreciated! This issue appeared after updating to Hcl 3.10. Any suggestions would be helpful.