问题
How bad it is to use Environment.SetEnvironmentVariable
in Azure Functions? Based on my initial observation it seems it is working as expected (ie. storing the value and returning when I asked using Environment.GetEnvironmentVariable
call) but not showing anywhere in the environment variables list when I open the function in Kudu explorer. Where it is setting, is it okay to use or any adverse effects of using it?
In my case, I have to get the user details using the token passed to Function headers. I don't want to keep retrieving the ID for the user again and again rather I want to cache some where. Thought of using Redis cache but a) I'm using V1 functions due to some libraries issue b)Just for one variable at least for now, I thought it is too costly. any other suggestions?
Thank you -Srikanth
回答1:
When you set the variable by Environment.SetEnvironmentVariable
, it will not show in application setting. But we can use it by Environment.GetEnvironmentVariable
as expected. Although the solution you mentioned is not so good, but it can implement your requirement. The adverse effect is when you restart the function app, the variables will be lost.
来源:https://stackoverflow.com/questions/64518359/environment-setenvironmentvariable-in-azure-function