Skip to content

Commit f48f9af

Browse files
authored
env vars added only cosmos db connection string needs to be added manually
1 parent cc83550 commit f48f9af

File tree

1 file changed

+50
-37
lines changed

1 file changed

+50
-37
lines changed

terraform-infrastructure/main.tf

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -69,43 +69,6 @@ resource "azurerm_storage_account" "runtime" {
6969
}
7070
}
7171

72-
# Linux Function App
73-
resource "azurerm_linux_function_app" "function_app" {
74-
name = var.function_app_name
75-
location = azurerm_resource_group.rg.location
76-
resource_group_name = azurerm_resource_group.rg.name
77-
service_plan_id = azurerm_service_plan.asp.id
78-
storage_account_name = azurerm_storage_account.runtime.name
79-
storage_account_access_key = azurerm_storage_account.runtime.primary_access_key
80-
81-
identity {
82-
type = "SystemAssigned"
83-
}
84-
85-
site_config {
86-
# Other configurations can go here
87-
application_stack {
88-
python_version = "3.10"
89-
}
90-
}
91-
92-
app_settings = {
93-
"FUNCTIONS_WORKER_RUNTIME" = "python"
94-
"WEBSITE_RUN_FROM_PACKAGE" = "1"
95-
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.appinsights.instrumentation_key
96-
"APPLICATIONINSIGHTS_CONNECTION_STRING" = azurerm_application_insights.appinsights.connection_string
97-
}
98-
99-
depends_on = [
100-
azurerm_service_plan.asp,
101-
azurerm_application_insights.appinsights
102-
]
103-
104-
provisioner "local-exec" {
105-
command = "echo Function App: ${self.name}"
106-
}
107-
}
108-
10972
# Assign Storage Blob Data Contributor role
11073
resource "azurerm_role_assignment" "blob_data_contributor" {
11174
scope = azurerm_storage_account.runtime.id
@@ -361,3 +324,53 @@ resource "null_resource" "cosmosdb_sql_role_assignment" {
361324
azurerm_cosmosdb_account.cosmosdb
362325
]
363326
}
327+
328+
# Linux Function App
329+
resource "azurerm_linux_function_app" "function_app" {
330+
name = var.function_app_name
331+
location = azurerm_resource_group.rg.location
332+
resource_group_name = azurerm_resource_group.rg.name
333+
service_plan_id = azurerm_service_plan.asp.id
334+
storage_account_name = azurerm_storage_account.runtime.name
335+
storage_account_access_key = azurerm_storage_account.runtime.primary_access_key
336+
337+
identity {
338+
type = "SystemAssigned"
339+
}
340+
341+
site_config {
342+
# Other configurations can go here
343+
application_stack {
344+
python_version = "3.10"
345+
}
346+
}
347+
348+
app_settings = {
349+
"FUNCTIONS_WORKER_RUNTIME" = "python"
350+
"FUNCTIONS_EXTENSION_VERSION" = "~4"
351+
"FUNCTIONS_NODE_BLOCK_ON_ENTRY_POINT_ERROR" = "true"
352+
"WEBSITE_RUN_FROM_PACKAGE" = "1"
353+
354+
"COSMOS_DB_ENDPOINT" = azurerm_cosmosdb_account.cosmosdb.endpoint
355+
"COSMOS_DB_KEY" = azurerm_cosmosdb_account.cosmosdb.primary_key
356+
357+
"invoicecontosostorage_STORAGE" = azurerm_storage_account.storage.primary_connection_string
358+
359+
"FORM_RECOGNIZER_ENDPOINT" = azurerm_cognitive_account.form_recognizer.endpoint
360+
"FORM_RECOGNIZER_KEY" = azurerm_cognitive_account.form_recognizer.primary_access_key
361+
362+
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.appinsights.instrumentation_key
363+
"APPLICATIONINSIGHTS_CONNECTION_STRING" = azurerm_application_insights.appinsights.connection_string
364+
}
365+
366+
depends_on = [
367+
azurerm_service_plan.asp,
368+
azurerm_application_insights.appinsights,
369+
azurerm_cosmosdb_account.cosmosdb
370+
371+
]
372+
373+
provisioner "local-exec" {
374+
command = "echo Function App: ${self.name}"
375+
}
376+
}

0 commit comments

Comments
 (0)