Skip to content

[Bug] Bug Title Here #1785

@NoobsDeSroobs

Description

@NoobsDeSroobs

Expected Behavior

os.getenv("erp_LANDING_STORE_CONNECTION_STRING").strip() returns the environment variable I have set under App Settings.

Actual Behavior

os.getenv("erp_LANDING_STORE_CONNECTION_STRING").strip() causes an Error.

Steps to Reproduce

As this works with another function app in my RG there is no guarantee you can reproduce it, but:
Deploy a FlexConsumption app (I used terraform and Visual Studio Code for the deployment using 'func azure functionapp publish')
Print the environment variables and see that the environment variable does not exist.

Relevant code being tried

@my_bp.service_bus_queue_trigger(arg_name="inputMessage", queue_name=f"{azure_environment}-test-queue", connection="SERVICE_BUS_CONNECTION_STRING")

def env_print_func(inputMessage: func.ServiceBusMessage):
    os.getenv("erp_LANDING_STORE_CONNECTION_STRING").strip()

Relevant log output

AttributeError: 'NoneType' object has no attribute 'strip'

requirements.txt file

Where are you facing this problem?

Production Environment (explain below)

Function app name

No response

Additional Information

'os.getenv("erp_LANDING_STORE_CONNECTION_STRING").strip()' gives me the error "'NoneType' object has no attribute 'strip'".

This seems similar to some other reports here, but I am on python 3.11, not 3.13, on FlexConsumption: Runtime Stack Python - 3.11
Further, when I print all environment variables using 'logger.warning(f"Env vars: {dict(os.environ)}")' I see 87 environment variables, but not the "erp_LANDING_STORE_CONNECTION_STRING" variable for some reason.

What is even stranger is that sometimes it works, and then it stops working again when processing multiple messages. Maybe it has something to do with new instances not being set up completely during start and scale out:
ServiceBus message 1 - Succeeds
ServiceBus message 2 - Succeeds
ServiceBus message 3 - Succeeds
ServiceBus message 4 - Fails
...
ServiceBus message 33 - Fails

Sometimes a manual restart fixes the issue for a little bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions