Azure函数中的Environment.SetEnvironmentVariable [英] Environment.SetEnvironmentVariable in Azure Function

查看:39
本文介绍了Azure函数中的Environment.SetEnvironmentVariable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Azure函数中使用 Environment.SetEnvironmentVariable 有多糟?根据我的初步观察,它似乎按预期方式工作(即,存储值并在我使用 Environment.GetEnvironmentVariable 调用进行询问时返回),但是当我打开函数时,环境变量列表中未显示任何位置在Kudu资源管理器中.设置在什么地方,可以使用吗?或者使用它有任何不利影响吗?

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?

就我而言,我必须使用传递给Function标头的令牌来获取用户详细信息.我不想一次又一次地获取用户的ID,而是想在某些地方缓存.考虑使用Redis缓存,但a)由于某些库问题,我正在使用V1函数b)至少目前仅针对一个变量,我认为这太昂贵了.还有其他建议吗?

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?

谢谢-Srikanth

Thank you -Srikanth

推荐答案

通过 Environment.SetEnvironmentVariable 设置变量时,它不会显示在应用程序设置中.但是我们可以按预期通过 Environment.GetEnvironmentVariable 使用它.尽管您提到的解决方案不是很好,但是它可以实现您的要求.不利影响是重新启动功能应用程序时,变量将丢失.

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.

这篇关于Azure函数中的Environment.SetEnvironmentVariable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆