1- resource "azurerm_app_service_plan " "pc" {
2- name = " plan-${ local . prefix } "
1+ resource "azurerm_service_plan " "pc" {
2+ name = " app- plan-${ local . prefix } "
33 location = azurerm_resource_group. pc . location
44 resource_group_name = azurerm_resource_group. pc . name
5- kind = " functionapp"
6- reserved = true
5+ os_type = " Linux"
6+
7+ sku_name = " EP1"
78
8- sku {
9- tier = " Dynamic"
10- size = " Y1"
11- }
129}
1310
14- resource "azurerm_function_app" "pcfuncs" {
15- name = " func-${ local . prefix } "
16- location = azurerm_resource_group. pc . location
17- resource_group_name = azurerm_resource_group. pc . name
18- app_service_plan_id = azurerm_app_service_plan. pc . id
19- storage_account_name = azurerm_storage_account. pc . name
20- storage_account_access_key = azurerm_storage_account. pc . primary_access_key
21- https_only = true
11+ resource "azurerm_linux_function_app" "pcfuncs" {
12+ name = " func-${ local . prefix } "
13+ location = azurerm_resource_group. pc . location
14+ resource_group_name = azurerm_resource_group. pc . name
15+ service_plan_id = azurerm_service_plan. pc . id
16+ storage_account_name = azurerm_storage_account. pc . name
17+
18+ virtual_network_subnet_id = azurerm_subnet. function_subnet . id
19+
20+ ftp_publish_basic_authentication_enabled = false
21+ webdeploy_publish_basic_authentication_enabled = false
22+
23+
24+ storage_uses_managed_identity = true
25+ https_only = true
2226
2327 identity {
2428 type = " SystemAssigned"
2529 }
2630
2731 app_settings = {
28- " ENABLE_ORYX_BUILD" = " true" ,
29- " SCM_DO_BUILD_DURING_DEPLOYMENT" = " true" ,
30- " FUNCTIONS_WORKER_RUNTIME" = " python" ,
31- " APP_INSIGHTS_IKEY" = azurerm_application_insights.pc_application_insights.instrumentation_key,
32- " APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.pc_application_insights.instrumentation_key,
32+ " FUNCTIONS_WORKER_RUNTIME" = " python" ,
33+ " APP_INSIGHTS_IKEY" = azurerm_application_insights.pc_application_insights.instrumentation_key,
34+
35+ # Remote build
36+ " BUILD_FLAGS" = " UseExpressBuild" ,
37+ " ENABLE_ORYX_BUILD" = " true"
38+ " SCM_DO_BUILD_DURING_DEPLOYMENT" = " 1" ,
39+ " XDG_CACHE_HOME" = " /tmp/.cache"
3340 " AzureWebJobsDisableHomepage" = true ,
3441
3542 # Animation Function
@@ -48,48 +55,50 @@ resource "azurerm_function_app" "pcfuncs" {
4855 " LOG_ANALYTICS_WORKSPACE_ID" = var.prod_log_analytics_workspace_id,
4956 }
5057
51- os_type = " linux"
52- version = " ~4"
5358 site_config {
54- linux_fx_version = " PYTHON|3.9 "
55- use_32_bit_worker_process = false
56- ftps_state = " Disabled"
59+ vnet_route_all_enabled = true
60+ application_insights_key = azurerm_application_insights . pc_application_insights . instrumentation_key
61+ ftps_state = " Disabled"
5762
5863 cors {
5964 allowed_origins = [" *" ]
6065 }
66+ application_stack {
67+ python_version = " 3.9"
68+ }
6169 }
62-
6370 lifecycle {
6471 ignore_changes = [
6572 tags
6673 ]
6774 }
6875}
6976
70- # Note: this must be in the same subscription as the rest of the deployed infrastructure
71- data "azurerm_storage_container" "output" {
72- name = var. output_container_name
73- storage_account_name = var. output_storage_account_name
77+
78+
79+ resource "azurerm_role_assignment" "function-app-storage-account-access" {
80+ scope = azurerm_storage_account. pc . id
81+ role_definition_name = " Storage Blob Data Owner"
82+ principal_id = azurerm_linux_function_app. pcfuncs . identity [0 ]. principal_id
7483}
7584
7685resource "azurerm_role_assignment" "function-app-animation-container-access" {
77- scope = data. azurerm_storage_container . output . resource_manager_id
86+ scope = data. azurerm_storage_account . output-storage-account . id
7887 role_definition_name = " Storage Blob Data Contributor"
79- principal_id = azurerm_function_app . pcfuncs . identity [0 ]. principal_id
88+ principal_id = azurerm_linux_function_app . pcfuncs . identity [0 ]. principal_id
8089
8190 depends_on = [
82- azurerm_function_app . pcfuncs
91+ azurerm_linux_function_app . pcfuncs
8392 ]
8493}
8594
8695resource "azurerm_role_assignment" "function-app-storage-table-data-contributor" {
8796 scope = azurerm_storage_account. pc . id
8897 role_definition_name = " Storage Table Data Contributor"
89- principal_id = azurerm_function_app . pcfuncs . identity [0 ]. principal_id
98+ principal_id = azurerm_linux_function_app . pcfuncs . identity [0 ]. principal_id
9099
91100 depends_on = [
92- azurerm_function_app . pcfuncs
101+ azurerm_linux_function_app . pcfuncs
93102 ]
94103}
95104
@@ -102,9 +111,9 @@ data "azurerm_log_analytics_workspace" "prod_log_analytics_workspace" {
102111resource "azurerm_role_assignment" "function-app-log-analytics-access" {
103112 scope = data. azurerm_log_analytics_workspace . prod_log_analytics_workspace . id
104113 role_definition_name = " Log Analytics Reader"
105- principal_id = azurerm_function_app . pcfuncs . identity [0 ]. principal_id
114+ principal_id = azurerm_linux_function_app . pcfuncs . identity [0 ]. principal_id
106115
107116 depends_on = [
108- azurerm_function_app . pcfuncs
117+ azurerm_linux_function_app . pcfuncs
109118 ]
110- }
119+ }
0 commit comments