Azure应用程序服务应用程序设置将保留在环境变量中。转到Azure门户添加您的应用程序设置或连接字符串值。然后,你可以在https://sitename.scm.azurewebsites.net
检查你的应用程序服务的环境变量,如果你想你webjobs共享这些设置,在您的webjob项目,创建appsettings.json:
{
"APPSETTING_AzureWebJobsDashboard": "",
"APPSETTING_AzureWebJobsStorage": "",
"SQLAZURECONNSTR_xxx": ""
}
在主()方法
private static void Main(string[] args)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
var configurations = builder.Build();
var services = new ServiceCollection()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(configurations["SQLAZURECONNSTR_xxx"]),
ServiceLifetime.Transient)
.BuildServiceProvider();
var host = new JobHost(new JobHostConfiguration
{
DashboardConnectionString = configurations["APPSETTING_AzureWebJobsDashboard"],
StorageConnectionString = configurations["APPSETTING_AzureWebJobsStorage"]
});
host.RunAndBlock();
}
这是不是试图找出路径网站配置上的应用程序服务简单
你应该纪念这个作为ANSW呃那么。 –
那么,这里有什么解决方案? –
你有什么理由让他们在一个单独的文件?如果你只在开发/调试中需要这个,你可以创建一个web配置变换,以便调试使用这个单独的文件,然后把它保留在变换之外或者没有一个,用于其他环境 –