Azure Asp.net core CloudConfigurationManager.GetSetting()为空
我有一个asp.NET4应用程序,它可以很好地工作,但我不能让它为asp.NETCore工作。文档中说,Azure Asp.net core CloudConfigurationManager.GetSetting()为空,azure,asp.net-core,azure-storage,Azure,Asp.net Core,Azure Storage,我有一个asp.NET4应用程序,它可以很好地工作,但我不能让它为asp.NETCore工作。文档中说,GetSetting在web.config或app.config文件中查找。 存储模拟器已打开 public void ConfigureServices(IServiceCollection services) { AzureConfig.Initialize(); } public static void Initialize() { //Always null
GetSetting
在web.config
或app.config
文件中查找。
存储模拟器已打开
public void ConfigureServices(IServiceCollection services)
{
AzureConfig.Initialize();
}
public static void Initialize()
{
//Always null
var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
}
根web.config文件:
<configuration>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;" />
</appSettings>
</configuration>
编辑,这也不起作用:
{
"ConnectionStrings": {
"DefaultConnection": "..."
"StorageConnectionString": "UseDevelopmentStorage=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"StorageConnectionString": "UseDevelopmentStorage=true"
}
在ASP.NET core中,设置已从web.config中移出,并移到appsettings.json中。查看文档,了解它是如何变化的: 另外,请看一下之前对类似问题的回答:
第二个链接正是我所需要的。谢谢
{
"ConnectionStrings": {
"DefaultConnection": "..."
"StorageConnectionString": "UseDevelopmentStorage=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"StorageConnectionString": "UseDevelopmentStorage=true"
}