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
This is more bad documentation from Azure, the article does indeed tell you to create an AppSetting and then the code tells you to retrieve a ConnectionString.
The alternative fix is to store the details as a ConnectionString and leave the code as is:
<add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=your-account;AccountKey=your-key" />
You have a fundamental mistake in your code.
First you set an AppSetting:
<configuration>
<appSettings>
<add key="StorageConnectionString"
value="DefaultEndpointsProtocol=https;AccountName=account- name;AccountKey=account-key" />
</appSettings>
</configuration>
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:
<configuration>
<connectionStrings>
<add name="StorageConnectionString"
connectionString="DefaultEndpointsProtocol=https;AccountName=account- name;AccountKey=account-key" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
And of course, you have to put your real values for Cloud Storage account and Storage Account key (account-name
will simply never work).