diff --git a/code/infra/function.tf b/code/infra/function.tf index b3ef222..30216b9 100644 --- a/code/infra/function.tf +++ b/code/infra/function.tf @@ -68,24 +68,24 @@ resource "azapi_resource" "function" { serverFarmId = azurerm_service_plan.service_plan.id storageAccountRequired = false vnetContentShareEnabled = true - vnetImagePullEnabled = true - virtualNetworkSubnetId = azapi_resource.subnet_function.id + vnetImagePullEnabled = false # Set to 'true' when pulling image from private Azure Container Registry vnetRouteAllEnabled = true + virtualNetworkSubnetId = azapi_resource.subnet_function.id siteConfig = { - autoHealEnabled = true - autoHealRules = { - actions = { - actionType = "LogEvent" - } - triggers = { - statusCodes = [ - "429", - "504", - "507", - "508" - ] - } - } + # autoHealEnabled = true # Enable to auto heal app based on configs + # autoHealRules = { + # actions = { + # actionType = "LogEvent" + # } + # triggers = { + # statusCodes = [ + # "429", + # "504", + # "507", + # "508" + # ] + # } + # } acrUseManagedIdentityCreds = false alwaysOn = true appSettings = [ @@ -105,26 +105,6 @@ resource "azapi_resource" "function" { name = "FUNCTIONS_EXTENSION_VERSION" value = "~4" }, - { - name = "FUNCTIONS_WORKER_RUNTIME" - value = "python" - }, - { - name = "FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED" - value = "1" - }, - { - name = "DOCKER_SHM_SIZE" - value = "268435456" - }, - { - name = "PYTHON_THREADPOOL_THREAD_COUNT" - value = "None" - }, - { - name = "PYTHON_ENABLE_DEBUG_LOGGING" - value = "0" - }, { name = "WEBSITE_CONTENTOVERVNET" value = "1" @@ -133,18 +113,6 @@ resource "azapi_resource" "function" { name = "WEBSITE_RUN_FROM_PACKAGE" value = "0" }, - { - name = "PYTHON_ENABLE_WORKER_EXTENSIONS" - value = "1" - }, - { - name = "ENABLE_ORYX_BUILD" - value = "1" - }, - { - name = "SCM_DO_BUILD_DURING_DEPLOYMENT" - value = "1" - }, { name = "AzureWebJobsStorage__accountName" value = azurerm_storage_account.storage.name @@ -157,6 +125,46 @@ resource "azapi_resource" "function" { name = "AzureWebJobsSecretStorageKeyVaultUri" value = azurerm_key_vault.key_vault.vault_uri }, + { + name = "WEBSITES_ENABLE_APP_SERVICE_STORAGE" # Disable when not running a container + value = "false" + }, + { + name = "DOCKER_REGISTRY_SERVER_URL" # Disable when not running a container + value = var.function_container_registry_url + }, + # { + # name = "FUNCTIONS_WORKER_RUNTIME" # Enable when running Python directly on the Function host + # value = "python" + # }, + # { + # name = "FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED" # Enable when running Python directly on the Function host + # value = "1" + # }, + # { + # name = "DOCKER_SHM_SIZE" # Enable when running Python directly on the Function host + # value = "268435456" + # }, + # { + # name = "PYTHON_THREADPOOL_THREAD_COUNT" # Enable when running Python directly on the Function host + # value = "None" + # }, + # { + # name = "PYTHON_ENABLE_DEBUG_LOGGING" # Enable when running Python directly on the Function host + # value = "0" + # }, + # { + # name = "PYTHON_ENABLE_WORKER_EXTENSIONS" # Enable when running Python directly on the Function host + # value = "1" + # }, + # { + # name = "ENABLE_ORYX_BUILD" # Enable when running Python directly on the Function host + # value = "1" + # }, + # { + # name = "SCM_DO_BUILD_DURING_DEPLOYMENT" # Enable when running Python directly on the Function host + # value = "1" + # }, { name = "MY_SECRET_CONFIG" value = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.key_vault_secret_sample.id})" diff --git a/code/infra/variables.tf b/code/infra/variables.tf index 1c273da..616b8cd 100644 --- a/code/infra/variables.tf +++ b/code/infra/variables.tf @@ -34,6 +34,16 @@ variable "tags" { } # Function variables +variable "function_container_registry_url" { + description = "Specifies the container image reference of the Azure Function." + type = string + sensitive = false + validation { + condition = startswith(var.function_container_registry_url, "https://") + error_message = "Please specify a valid container image reference." + } +} + variable "function_container_image" { description = "Specifies the container image reference of the Azure Function." type = string diff --git a/config/PerfectThymeTech/vars.tfvars b/config/PerfectThymeTech/vars.tfvars index 9c19dfb..9be4ab5 100644 --- a/config/PerfectThymeTech/vars.tfvars +++ b/config/PerfectThymeTech/vars.tfvars @@ -5,10 +5,11 @@ prefix = "myfunc" tags = {} # Function variables -function_container_image = "ghcr.io/perfectthymetech/azurefunctionpython:main" -function_sku = "P0v3" -function_sku_cpus = 1 -function_health_path = "/v1/health/heartbeat" +function_container_registry_url = "https://ghcr.io" +function_container_image = "ghcr.io/perfectthymetech/azurefunctionpython:main" +function_sku = "P0v3" +function_sku_cpus = 1 +function_health_path = "/v1/health/heartbeat" # Network variables vnet_id = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1d094/resourceGroups/mycrp-prd-function-network-rg/providers/Microsoft.Network/virtualNetworks/mycrp-prd-function-vnet001"