从visual studio部署功能应用程序后,在azure门户中获取环境变量 [英] Get environment variable in azure portal after deploying function app from visual studio
问题描述
我在本地获取自定义值并通过 System.Environment.GetEnvironmentVariable(name,EnvironmentVariableTarget.Process);接着是以下链接
in local.setting.json i wriiten custom values in locally am getting through System.Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process); followed by below link
- 我从.git中删除了local.setting.json然后也没有得到
- i removed local.setting.json from .git ignore then also not getting
- 在azure中获取环境变量是否有任何解决方案请建议我
-unable to get environment variable in azure is there any solution please suggest me
推荐答案
您需要添加Azure的应用程序设置功能。
You need to add in the Application settings of Azure function.
进入Azure门户 - >功能应用 - >选择您的函数
à 应用程序设置
Go into the Azure Portal -> Function Apps -> Select your Function àApplication settings
using System;
public static void Run(TimerInfo myTimer, ILogger log)
{
log.LogInformation(
" C#Timer触发函数执行于:{DateTime.Now}");
  log.LogInformation(GetEnvironmentVariable(的" YourAppSettingName" 强>));
}
public static string GetEnvironmentVariable(string name)
{
 返回姓名+":" + System.Environment.GetEnvironmentVariable(name,EnvironmentVariableTarget.Process);
}
"C# Timer trigger function executed at: {DateTime.Now}"); log.LogInformation(GetEnvironmentVariable("YourAppSettingName")); } public static string GetEnvironmentVariable(string name) { return name + ": " + System.Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process); }
这篇关于从visual studio部署功能应用程序后,在azure门户中获取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!