@@ -7,7 +7,7 @@ resource "azurerm_service_plan" "service_plan" {
77 # maximum_elastic_worker_count = 20
88 os_type = " Linux"
99 per_site_scaling_enabled = false
10- sku_name = " P1v3 "
10+ sku_name = var . function_sku
1111 worker_count = 1 # Update to '3' for production
1212 zone_balancing_enabled = false # Update to 'true' for production
1313}
@@ -50,7 +50,7 @@ resource "azapi_resource" "function" {
5050 }
5151
5252 body = jsonencode ({
53- kind = " functionapp,linux"
53+ kind = " functionapp,linux,container "
5454 properties = {
5555 clientAffinityEnabled = false
5656 clientCertEnabled = false
@@ -64,14 +64,28 @@ resource "azapi_resource" "function" {
6464 publicNetworkAccess = " Disabled"
6565 redundancyMode = " None"
6666 reserved = true
67- scmSiteAlsoStopped = false
67+ scmSiteAlsoStopped = true
6868 serverFarmId = azurerm_service_plan.service_plan.id
6969 storageAccountRequired = false
7070 vnetContentShareEnabled = true
71+ vnetImagePullEnabled = true
7172 virtualNetworkSubnetId = azapi_resource.subnet_function.id
7273 vnetRouteAllEnabled = true
7374 siteConfig = {
74- autoHealEnabled = false
75+ autoHealEnabled = true
76+ autoHealRules = {
77+ actions = {
78+ actionType = " LogEvent"
79+ }
80+ triggers = {
81+ statusCodes = [
82+ " 429" ,
83+ " 504" ,
84+ " 507" ,
85+ " 508"
86+ ]
87+ }
88+ }
7589 acrUseManagedIdentityCreds = false
7690 alwaysOn = true
7791 appSettings = [
@@ -80,8 +94,12 @@ resource "azapi_resource" "function" {
8094 value = azurerm_application_insights.application_insights.connection_string
8195 },
8296 {
83- name = " APPINSIGHTS_INSTRUMENTATIONKEY"
84- value = azurerm_application_insights.application_insights.instrumentation_key
97+ name = " AZURE_FUNCTIONS_ENVIRONMENT"
98+ value = " Production"
99+ },
100+ {
101+ name = " FUNCTIONS_WORKER_PROCESS_COUNT"
102+ value = " ${ var . function_sku_cpus } "
85103 },
86104 {
87105 name = " FUNCTIONS_EXTENSION_VERSION"
@@ -91,6 +109,22 @@ resource "azapi_resource" "function" {
91109 name = " FUNCTIONS_WORKER_RUNTIME"
92110 value = " python"
93111 },
112+ {
113+ name = " FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED"
114+ value = " 1"
115+ },
116+ {
117+ name = " DOCKER_SHM_SIZE"
118+ value = " 268435456"
119+ },
120+ {
121+ name = " PYTHON_THREADPOOL_THREAD_COUNT"
122+ value = " None"
123+ },
124+ {
125+ name = " PYTHON_ENABLE_DEBUG_LOGGING"
126+ value = " 0"
127+ },
94128 {
95129 name = " WEBSITE_CONTENTOVERVNET"
96130 value = " 1"
@@ -115,6 +149,14 @@ resource "azapi_resource" "function" {
115149 name = " AzureWebJobsStorage__accountName"
116150 value = azurerm_storage_account.storage.name
117151 },
152+ {
153+ name = " AzureWebJobsSecretStorageType"
154+ value = " keyvault"
155+ },
156+ {
157+ name = " AzureWebJobsSecretStorageKeyVaultUri"
158+ value = azurerm_key_vault.key_vault.vault_uri
159+ },
118160 {
119161 name = " MY_SECRET_CONFIG"
120162 value = " @Microsoft.KeyVault(SecretUri=${ azurerm_key_vault_secret . key_vault_secret_sample . id } )"
@@ -126,15 +168,18 @@ resource "azapi_resource" "function" {
126168 functionsRuntimeScaleMonitoringEnabled = false
127169 ftpsState = " Disabled"
128170 healthCheckPath = var.function_health_path
129- http20Enabled = false
171+ http20Enabled = true
130172 ipSecurityRestrictionsDefaultAction = " Deny"
131- linuxFxVersion = " Python |${ var . function_python_version } "
173+ linuxFxVersion = " DOCKER |${ var . function_container_image } "
132174 localMySqlEnabled = false
133175 loadBalancing = " LeastRequests"
134176 minTlsVersion = " 1.2"
177+ minTlsCipherSuite = " TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
135178 minimumElasticInstanceCount = 0
136179 numberOfWorkers = 1
137180 preWarmedInstanceCount = 0
181+ remoteDebuggingEnabled = false
182+ requestTracingEnabled = true
138183 scmMinTlsVersion = " 1.2"
139184 scmIpSecurityRestrictionsUseMain = false
140185 scmIpSecurityRestrictionsDefaultAction = " Deny"
@@ -144,6 +189,18 @@ resource "azapi_resource" "function" {
144189 }
145190 }
146191 })
192+
193+ schema_validation_enabled = false
194+ # ignore_body_changes = [
195+ # "properties.siteConfig.appSettings"
196+ # ]
197+ depends_on = [
198+ azurerm_private_endpoint . key_vault_private_endpoint ,
199+ azurerm_private_endpoint . storage_private_endpoint_blob ,
200+ azurerm_private_endpoint . storage_private_endpoint_file ,
201+ azurerm_private_endpoint . storage_private_endpoint_queue ,
202+ azurerm_private_endpoint . storage_private_endpoint_table ,
203+ ]
147204}
148205
149206data "azurerm_monitor_diagnostic_categories" "diagnostic_categories_function" {
0 commit comments