Is there a limit as to the number of application settings I can have configured for my app?

Michelle Blum 806 Reputation points Microsoft Employee
2021-03-29T16:11:59.557+00:00

My Api has stopped loading in Azure with no code changes. The Web App seems to be failing to startup with the error,
“The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is xxxx bytes long. Remove some environment variables and try again.”

The error makes it sound like this is a limit. However, if there is some sort of limit here then why would the error suddenly start throwing without changes to the api code?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,949 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 26,136 Reputation points Microsoft Employee
    2021-03-29T18:50:30.747+00:00

    There is a known limitation of the .Net Framework where the length of an environment block is limited to 65535 bytes.

    As to a resolution or workaround, here we have a few options,

    • Reduce the number of AppSettings in the application
    • Save some settings in another store such as Redis, SQL, NoSQL, etc.
    • Separate the variables into multiple app services
    • Store the environment variables into a .txt file in a storage account and access them from the file in storage

    Regarding why this would happen suddenly, the error occurs during code compilation.
    If say an environment variable is added during the build process and you are already near the threshold due to a high number of configured app settings, then any system generated flag can cause the error to throw.
    The .Net source code showing where this error throws can be referenced here: Process.cs (microsoft.com)

    Since this is being implemented by the .Net framework, it would not be possible to increase the limit.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful