Hello @Kristoffer Strekerud
Based on the code you provided, it looks like you have correctly specified the requirements.txt
file in the azurerm_function_app_function
resource.
However, it's possible that the packages are not being installed because the requirements.txt
file is not being found or is not being processed correctly.
One thing you can try is to add a WEBSITE_RUN_FROM_PACKAGE
app setting to your azurerm_linux_function_app
resource. This setting tells Azure Functions to run your function app from a package file, which includes your code and dependencies. You can create a package file by running pip install -r requirements.txt -t .
in the root directory of your function app, which will install the packages specified in requirements.txt
in the site-packages
directory.
Then, you can create a zip file of your function app by running zip -r functionapp.zip .
in the root directory of your function app. Finally, you can upload the zip file to a storage account and set the WEBSITE_RUN_FROM_PACKAGE
app setting to the URL of the zip file.
Here's an example of how to add the WEBSITE_RUN_FROM_PACKAGE
app setting to your azurerm_linux_function_app
resource xx app_settings = {
AzureWebJobsStorage = azurerm_storage_account.storage_account_func.primary_connection_string
FUNCTIONS_WORKER_RUNTIME = python
APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.app_insights.instrumentation_key
KeyVaultName = azurerm_key_vault.key_vault.name
SCM_DO_BUILD_DURING_DEPLOYMENT = true
ENABLE_ORYX_BUILD = true
WEBSITE_RUN_FROM_PACKAGE = "https://.blob.core.windows.net//functionapp.zip"
}
Replace the name of your storage account and container, respectively.
I hope this helps