.NET Core Azure WebJobs不会从Azure应用程序设置中读取 [英] .NET Core Azure WebJobs does not read from Azure Application Settings

查看:105
本文介绍了.NET Core Azure WebJobs不会从Azure应用程序设置中读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与Azure门户中的相应ConnectionString一起运行的应用程序服务。 ConnectionString指向Azure SQL Server。

I have an app service running with it's respective ConnectionString from Azure Portal. The ConnectionString is point to Azure SQL Server.

我有一个WebJob,其中包含以下appsettings.json

I have a WebJob with the following appsettings.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Add your connection string"
  }
}

当我运行Web Job时,它似乎并没有从蔚蓝中提取Connection字符串门户网站,但它在appsettings.json中使用了我的默认ConnectionStrings。

When I run the Web Job, it doesn't seem to pull the Connection strings from the azure portal, but it uses my default ConnectionStrings in appsettings.json.

[02/13/2017 08:45:27 > 2942c6: SYS INFO] Status changed to Initializing
[02/13/2017 08:45:27 > 2942c6: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[02/13/2017 08:45:27 > 2942c6: SYS INFO] Status changed to Running
[02/13/2017 08:45:27 > 2942c6: INFO] 
[02/13/2017 08:45:27 > 2942c6: INFO] D:\local\Temp\jobs\triggered\TestConnectionString\32vmiek4.2av>dotnet TestConnectionString.dll 
[02/13/2017 08:45:29 > 2942c6: INFO] Add your connection string


推荐答案

请确保您构建配置时,请调用 AddEnvironmentVariables()。例如

Make sure you call AddEnvironmentVariables() when building your configuration. e.g.

var builder = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json")
    .AddEnvironmentVariables();

这篇关于.NET Core Azure WebJobs不会从Azure应用程序设置中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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