2016-09-27 18 views
3

我一直在試圖訪問Azure的Blob存儲在dotnet的核心與下面的代碼不兼容:CloudConfigurationManager與.NetCoreApp

CloudStorageAccount account = CloudStorageAccount.Parse(
      CloudConfigurationManager.GetSetting("<MyStorageName>_AzureStorageConnectionString") 
      ); 

在此之前我已經安裝了所需的Azure的SDK,並更新到DOTNET核心兼容版本,那麼,由於CloudConfigurationManager失蹤,我安裝了Microsoft.WindowsAzure.ConfigurationManager,根據this的答案。已經更新後,這個包爲好,包還原失敗,出現以下錯誤信息:

Package Microsoft.WindowsAzure.ConfigurationManager 3.2.1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.WindowsAzure.ConfigurationManager 3.2.1 supports: net40 (.NETFramework,Version=v4.0) 
One or more packages are incompatible with .NETCoreApp,Version=v1.0. 

有爲了任何選項來獲得CloudConfigurationManager工作或做我需要找到一個解決辦法?

+0

您使用雲服務嗎?你真的需要使用CloudConfigurationManager還是ConfigurationManager足夠了? – Thomas

+0

@Thomas我的確在使用雲服務,我正在關注[本教程](https://azure.microsoft.com/en-gb/documentation/articles/vs-storage-aspnet5-getting-started-blobs/ ) – WizardOfMenlo

+0

好吧,我想知道,如果你使用的是一個web應用程序,CloudConfigurationManager並沒有真正的敏感 – Thomas

回答

4

軟件包Microsoft.WindowsAzure.ConfigurationManager 3.2.1與netcoreapp1.0(.NETCoreApp,版本= v1.0)不兼容。包裝Microsoft.WindowsAzure.ConfigurationManager 3.2.1支持:net40(.NETFramework,版本= V4.0)

在ASP.NET核心,設置已被轉移到appsettings.json。據我所知,現在不支持在.NETCoreApp中使用CloudConfigurationManager

有關解決方法,你可以按照下面的代碼來實現你的account

CloudStorageAccount account = new CloudStorageAccount(
    new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
     "<storage-accountname>", 
     "<storage-accountkey>"), true); 

此外,您可以參考此相關SO thread。此外,爲了更好地理解.NET Core中的配置,您可以按照此tutorial

相關問題