Question

I'm trying to upload a file to a Windows Azure storage blob. I feel like I'm trying something really basic. I have a new ASP.NET MVC 4 Web Application (as in File->New Project...). When I get to the line shown below that reads "CloudStorageAccount.FromConfigurationSetting", an exception is thrown. That exception has the following information:

Type: System.Runtime.InteropServices.SEHException
Message: External component has thrown an exception.

Here is the code that I have:

// Setup the Windows Aure blob client
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetting) => configSetting(RoleEnvironment.GetConfigurationSettingValue(configName)));
CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("BlobStorage");

What am I doing wrong?

Was it helpful?

Solution

I feel the way you're trying to do is wrong.So you can use below mentioned methods for do your task.I have mentioned very useful link with this post.Check that also.

How to: Programmatically access blob storage ?

Retrieving your connection string

Method 1 : You can use the CloudStorageAccount type to represent your Storage Account information is as below.

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

Method 2 : If you are creating an application with no reference to Microsoft.WindowsAzure.CloudConfigurationManager, and your connection string is located in the web.config or app.config then,

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

You can have great amount of information by using How to use the Windows Azure Blob Storage Service in .NET

I hope this will help to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top