terraform-provider-azurerm
terraform-provider-azurerm copied to clipboard
azurerm_linux_function_app for node runtimes version 4 don't load in app settings and env variables.
Is there an existing issue for this?
- [X] I have searched the existing issues
Community Note
- Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
1.2.8
AzureRM Provider Version
3.21.1
Affected Resource(s)/Data Source(s)
azurerm_linux_function_app
Terraform Configuration Files
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.21.1"
}
}
required_version = ">= 1.2.8"
}
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}
resource "azurerm_resource_group" "test_resource_group" {
name = "test-resource-group"
location = "australia east"
}
resource "azurerm_service_plan" "test_linux_app" {
name = "ASP-test-linux-app"
resource_group_name = azurerm_resource_group.test_resource_group.name
location = azurerm_resource_group.test_resource_group.location
os_type = "Linux"
sku_name = "Y1"
}
resource "azurerm_storage_account" "test_linux_app" {
name = "testlinuxapp234"
resource_group_name = azurerm_resource_group.test_resource_group.name
location = azurerm_resource_group.test_resource_group.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_linux_function_app" "test_linux_app" {
name = "test-linux-app-2348234"
resource_group_name = azurerm_resource_group.test_resource_group.name
location = azurerm_resource_group.test_resource_group.location
service_plan_id = azurerm_service_plan.test_linux_app.id
storage_account_name = azurerm_storage_account.test_linux_app.name
storage_account_access_key = azurerm_storage_account.test_linux_app.primary_access_key
app_settings = {
# // These environment variables have to be set, otherwise app settings do not get loaded as environment variables
# // https://github.com/Azure/Azure-Functions/issues/1696
# "FUNCTIONS_WORKER_RUNTIME" = "node"
}
# functions_extension_version = "~3"
site_config {
cors {
allowed_origins = ["*"]
}
}
}
Debug Output/Panic Output
N/A
Expected Behaviour
Suppose we create a http triggered js function like:
module.exports = async function (context, req) {
context.res = {
// status: 200, /* Defaults to 200 */
body: process.env['AzureWebJobsStorage']
};
}
with function.json
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
When I trigger this function, I expect to receive a response like:
DefaultEndpointsProtocol=https;AccountName=testlinuxapp234;AccountKey=ekBAuA5ATKvJI/y1X2XVqNeV2tQHXNlwGJ19PpXoEYXEr//mv4DRQEyyKs2RNSG4ZzalNKeO76js+AStFz4VtQ==;EndpointSuffix=core.windows.net
Actual Behaviour
I get an empty response (it's undefined)
Steps to Reproduce
- terraform apply
- func function new
- Create a node app.
- with a http trigger
- Copy the following code into the trigger:
module.exports = async function (context, req) {
context.res = {
// status: 200, /* Defaults to 200 */
body: process.env['AzureWebJobsStorage']
};
}
- func azure functionapp publish {funcAppName}
- Trigger the http trigger.
If you uncomment # "FUNCTIONS_WORKER_RUNTIME" = "node" and # functions_extension_version = "~3" (from the terraform config), the function works as expected.
Important Factoids
No response
References
Based off this issue https://github.com/Azure/Azure-Functions/issues/1696