Environment.SetEnvironmentVariable in Azure Function

≯℡__Kan透↙ 提交于 2021-02-10 20:15:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!