Azure / azure-functions-on-container-apps

Docs , samples and issues for Azure Functions on Azure Container Apps
MIT License
71 stars 16 forks source link

Inconsistency between Scaling Rules Configuration and Environment Variables ':' char should be replaced by '__' #63

Closed AlexMasson closed 2 months ago

AlexMasson commented 3 months ago

Which trigger/binding are you using?

Which language are you using? C#

Expected behavior The scaling rule must work.

Actual behavior I have an Azure Function with a ServiceBusTrigger. The trigger is configured according to the documentation, with environment variables containing the ":" character in the name to hierarchize the app settings.

[ServiceBusTrigger("%ImagoSdk:ServiceBus:Topics:InternalBigData%", Connection = "ImagoSdk:ServiceBus:ConnectionString", IsSessionsEnabled = true)]

The app settings are registered as environment variables in the Azure Function using "__" instead of ":" for Linux compatibility.

image

When the function is deployed in an Azure Function on Container App, the scaling rule uses the app settings name with ":", thus it doesn't work.

image

Additionally, when a scaling rule does not work, the ContainerApp remains up 24/7, which can be problematic if unnoticed, as it prevents stopping, starting, or restarting the Azure Function.

To Reproduce

Logs Here are some SystemLogs from the ContainerApp

error parsing azure service bus metadata: no connection setting given
raorugan commented 3 months ago

hi @AlexMasson , can you please let us know how did you create this function app and what command did you use to create?

AlexMasson commented 3 months ago

Hi @raorugan, here is a zip file containing :

The bicep file was deployed using this CLI command : az deployment group create --resource-group xxx --template-file function-aca.bicep

I didn't create a Log Analytics Workspace for this example, but you'll have to if you want to get this trace in system logs of the container app : error parsing azure service bus metadata: no connection setting given

This exemple display a function app which never scale down, because the scaling rule is not working.

ContainerAppIssue.zip

krishnajaju commented 3 months ago

Thanks for all the details, @AlexMasson. Can you please try wrapping the Connection setting name in double percent signs (%%) and let us know if scaling works as expected?

[ServiceBusTrigger("%ImagoSdk:ServiceBus:Topics:InternalBigData%", Connection = "%ImagoSdk:ServiceBus:ConnectionString%", IsSessionsEnabled = true)]

AlexMasson commented 3 months ago

Hello @krishnajaju , thank you for your response.

I tried this solution:

krishnajaju commented 3 months ago

Thanks for trying it out @AlexMasson and apologies it did not resolve the issue. We have identified a bug in our system, and we will work on fixing this soon. As a temporary work-around, I would suggest having two app settings for service bus connection string, one with delimiter : and another with delimiter __ pointing to the same ServiceBus connection string, until we fix this issue. Please let me know if this workaround helps. We will let you know once fix for this issue is rolled out.

AlexMasson commented 3 months ago

Ok thank you @krishnajaju I will do that. Keep me informed.

AlexMasson commented 2 months ago

Hello @krishnajaju , this work-around is unfortunately not working, I have this kind of error during the deployment : Env variable name 'xx:xx:xx' contains invalid character, regex used for validation is '^[-._a-zA-Z][-._a-zA-Z0-9]*$'

krishnajaju commented 2 months ago

Thanks for trying it out @AlexMasson. We are currently working on fixing this bug, and we will update you once the fix is rolled out. Until then, can you please reference app settings for Connection attribute without any hierarchy (without any : or __)?

krishnajaju commented 2 months ago

Hi @AlexMasson, the bug has been fixed and the update has been rolled out. Please let us know if you encounter any further issues.