@@ -1617,12 +1617,16 @@ resource functionApp 'Microsoft.Web/sites@2022-03-01' = {
16171617 appSettings: [
16181618 { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' }
16191619 { name: 'FUNCTIONS_WORKER_RUNTIME', value: 'dotnet-isolated' }
1620- { name: 'AzureWebJobsStorage ', value: storageConnectionString }
1621- { name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING ', value: storageConnectionString }
1620+ { name: 'AzureWebJobsStorage__accountName ', value: storageAccount.name }
1621+ { name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING__accountName ', value: storageAccount.name }
16221622 { name: 'WEBSITE_CONTENTSHARE', value: functionAppName }
1623+ { name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: appInsights.properties.ConnectionString }
16231624 ]
16241625 }
16251626 }
1627+ identity: {
1628+ type: 'SystemAssigned'
1629+ }
16261630}
16271631```
16281632
@@ -1677,6 +1681,7 @@ resource functionApp 'Microsoft.Web/sites@2023-12-01' = {
16771681 appSettings: [
16781682 { name: 'AzureWebJobsStorage__accountName', value: storageAccount.name }
16791683 { name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: appInsights.properties.ConnectionString }
1684+ { name: 'APPLICATIONINSIGHTS_AUTHENTICATION_STRING', value: 'Authorization=AAD' }
16801685 ]
16811686 }
16821687 }
@@ -1686,6 +1691,9 @@ resource functionApp 'Microsoft.Web/sites@2023-12-01' = {
16861691}
16871692```
16881693
1694+ > [ !NOTE]
1695+ > When using ` APPLICATIONINSIGHTS_AUTHENTICATION_STRING ` with ` Authorization=AAD ` , you must also assign the ** Monitoring Metrics Publisher** role to the function app's managed identity on the Application Insights resource.
1696+
16891697For complete Bicep examples, see the [ Flex Consumption Bicep samples] ( https://github.com/Azure-Samples/azure-functions-flex-consumption-samples/tree/main/IaC/bicep ) .
16901698
16911699#### [ Terraform] ( #tab/terraform )
@@ -1702,14 +1710,19 @@ resource "azurerm_service_plan" "consumption" {
17021710}
17031711
17041712resource "azurerm_linux_function_app" "consumption" {
1705- name = var.function_app_name
1706- location = azurerm_resource_group.rg.location
1707- resource_group_name = azurerm_resource_group.rg.name
1708- service_plan_id = azurerm_service_plan.consumption.id
1709- storage_account_name = azurerm_storage_account.sa.name
1710- storage_account_access_key = azurerm_storage_account.sa.primary_access_key
1713+ name = var.function_app_name
1714+ location = azurerm_resource_group.rg.location
1715+ resource_group_name = azurerm_resource_group.rg.name
1716+ service_plan_id = azurerm_service_plan.consumption.id
1717+ storage_account_name = azurerm_storage_account.sa.name
1718+ storage_uses_managed_identity = true
1719+
1720+ identity {
1721+ type = "SystemAssigned"
1722+ }
17111723
17121724 site_config {
1725+ application_insights_connection_string = azurerm_application_insights.appInsights.connection_string
17131726 application_stack {
17141727 dotnet_version = "8.0"
17151728 use_dotnet_isolated_runtime = true
0 commit comments