Azure-functions-host: Maximum length of an environment variable

Created on 29 Oct 2020  路  10Comments  路  Source: Azure/azure-functions-host

I'm using Azure Function App hosted on an S1 Linux plan and I've noticed that whenever I set (through Azure Portal configuration ui) environment variable which is longer than 53 characters then it's getting trimmed.

Example:
Environment variable name: Section1__Subsection1__Subsection1OfSection1__ConnectionString

Portal allows to set such environment variable and after saving it still displays full length of it. But when I go to Kudu and open an appsettings view I can see it's trimmed to Section1__Subsection1__Subsection1OfSection1__Connect.

Works fine when app is hosted on Windows plan.

Couldn't find it documented anywhere.

needs-investigation

Most helpful comment

The docs should be updated soon. The limit has been set to 100 characters based on the telemetry. Adding an env. variable name with a length longer than that would fail right away instead of getting truncated at runtime (once the changes are deployed ETA to start : 2-3 weeks).

All 10 comments

@fabiocav / @mhoeger , I am able to repro this scenario. Like explained, the Env variable shows around 50 characters while using Linux OS and more than 50 characters while using Windows OS in Kudu.

Is this something that could be corrected

We just hit this now, this is ridiculous... So glad this issue exists because it's just bitten us big time... 馃槚

@ahmelsayed - do you know why there's a max length on environment variables on Linux or would this be a question for Jenny's team?

I have opened an internal workitem to start enforcing this limit when an attempt is made to add such a long env. variable from Portal or other clients. This should prevent the key from getting clipped silently before being passed to the app and make the failures more obvious.
We will also check if the allowed length should be longer than 64 characters as well.

For now are you able to work around this limitation by shortening the length?

@balag0 Yes, this limitation was easily worked around by just shortening the length :)

I just ran into this issue as well. Spent ages figuring out what the problem was.
It would be good if this was somehow at least mentionned in the documentation

Or to increase the limitation in terms of length. Would love to know the reasoning behind it.

This feels a bit like '640kb ought to be enough for everybody'.

The docs should be updated soon. The limit has been set to 100 characters based on the telemetry. Adding an env. variable name with a length longer than that would fail right away instead of getting truncated at runtime (once the changes are deployed ETA to start : 2-3 weeks).

The docs should be updated soon. The limit has been set to 100 characters based on the telemetry. Adding an env. variable name with a length longer than that would fail right away instead of getting truncated at runtime (once the changes are deployed ETA to start : 2-3 weeks).

100 is still a small amount for those of us who use nested configs, _especially_ as double underscore __ is the nested structure identifier which wastes two chars per level.

Was this page helpful?
0 / 5 - 0 ratings