Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Asp.net core CloudConfigurationManager.GetSetting()为空_Azure_Asp.net Core_Azure Storage - Fatal编程技术网

Azure Asp.net core CloudConfigurationManager.GetSetting()为空

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

我有一个asp.NET4应用程序,它可以很好地工作,但我不能让它为asp.NETCore工作。文档中说,
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"
}