azure-functions-host icon indicating copy to clipboard operation
azure-functions-host copied to clipboard

Maximum length of an environment variable

Open kamilzzz opened this issue 5 years ago • 13 comments

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.

kamilzzz avatar Oct 29 '20 15:10 kamilzzz

@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

v-anvari avatar Nov 06 '20 15:11 v-anvari

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

ElvenSpellmaker avatar Feb 05 '21 22:02 ElvenSpellmaker

@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?

mhoeger avatar Feb 05 '21 22:02 mhoeger

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 avatar Feb 15 '21 07:02 balag0

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

kamilzzz avatar Feb 28 '21 22:02 kamilzzz

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

fgheysels avatar Mar 08 '21 09:03 fgheysels

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

tomkerkhove avatar Mar 08 '21 09:03 tomkerkhove

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

fgheysels avatar Mar 08 '21 16:03 fgheysels

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).

balag0 avatar Mar 09 '21 09:03 balag0

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.

ElvenSpellmaker avatar Apr 03 '21 12:04 ElvenSpellmaker

Here is an example of the limit of 100 being passed with a setting. This is I believe still the recommended way of overriding host.json settings:

AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__samplingPercentageDecreaseTimeout

solonrice avatar Dec 09 '21 22:12 solonrice

Longterm we need a different solution for configuring nested configs via app settings. But we can increase the limit to 150 short term to improve things a bit.

balag0 avatar Dec 10 '21 00:12 balag0

Hi @balag0 Has there been any updates on increasing the limit? Just hit the limit of 100 today while attempting to deploy AzureFunctionsJobHost__logging__logLevel__Microsoft__Azure__WebJobs__Extensions__Storage__Blobs__Listeners__BlobListener as an appsetting. Thanks

ttq-ak avatar Sep 14 '22 10:09 ttq-ak

This is a silly limit, not sure why it is actually an idea at all.. we've been using it to override AzureFunctionsJobHost__logging__applicationInsights__DependencyTrackingOptions__enableSqlCommandTextInstrumentation running on Windows for ages and now we're in the process of migrating our Azure Functions to run on Linux and hit this one.. just for giggles I took it out of the CICD pipeline deployment so I could at least have the deployment complete and then went and manually added this setting and the Function still runs without any issues so I don't see why to limit this at all if it is allowed from the AZ Portal and it still seems to work on Linux.

carlos-suarez avatar Oct 19 '22 19:10 carlos-suarez