2017-02-13 69 views
3

我從Azure的門戶網站它的各自的ConnectionString運行一個應用程序服務中讀取。 ConnectionString指向Azure SQL Server。 Azure Portal Application Settings for Connection String.NET核心Azure的WebJobs不從Azure應用程序設置

我有以下appsettings.json一個WebJob

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

當我運行Web作業,它似乎不拉從蔚藍的門戶網站的連接字符串,但它使用我的默認Appsettings.json中的ConnectionStrings。

[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 
+0

?你也使用VS2015更新3或VS2017 RC1或其他? – juvchan

+0

@juvchan嗨,我使用.NET的核心1.0.3和VS 2017年RC –

回答

5

確保在構建配置時致電AddEnvironmentVariables()。例如

你用什麼具體的.NET Core版本
var builder = new ConfigurationBuilder() 
    .SetBasePath(Directory.GetCurrentDirectory()) 
    .AddJsonFile("appsettings.json") 
    .AddEnvironmentVariables(); 
+0

這完美地工作@DavidEbbo –