Connecting Azure Blob with Azure Website

后端 未结 2 1965
悲哀的现实
悲哀的现实 2021-02-06 00:59

I\'m trying to connect an Azure website to an Azure blob (where I intend to host some files in a container and then grab them from my website).

I started out with this t

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 01:39

    You have a fundamental mistake in your code.

    First you set an AppSetting:

     
        
           
        
     
    

    Then you try to get a connection string:

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
    

    This will simply not work. When set AppSetting, you need to read AppSetting. When you set ConnectionString, you need to read Connection String.

    So, the solution to be just keep the web.config as is, and change the line where you get storage account to:

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
    

    Or keep your line for Connection strings but change web.config to:

     
        
           
        
     
    

    And of course, you have to put your real values for Cloud Storage account and Storage Account key (account-name will simply never work).

提交回复
热议问题