【问题标题】:Unable to Upload File to Windows Azure Blob无法将文件上传到 Windows Azure Blob
【发布时间】:2013-01-01 01:56:47
【问题描述】:

我正在尝试将文件上传到 Windows Azure 存储 Blob。我觉得我正在尝试一些非常基本的东西。我有一个新的 ASP.NET MVC 4 Web 应用程序(如 File->New Project...)。当我到达下面显示的“CloudStorageAccount.FromConfigurationSetting”行时,会引发异常。该异常具有以下信息:

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

这是我的代码:

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

我做错了什么?

【问题讨论】:

    标签: c# .net asp.net-mvc-4 azure-storage azure-blob-storage


    【解决方案1】:

    我觉得你尝试做的方式是错误的。所以你可以使用下面提到的方法来完成你的任务。我在这篇文章中提到了非常有用的链接。也检查一下。

    如何:以编程方式访问 Blob 存储?

    检索您的连接字符串

    方法一:您可以使用CloudStorageAccount类型来表示您的Storage Account信息如下。

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

    方法二:如果你创建的应用程序没有引用Microsoft.WindowsAzure.CloudConfigurationManager,而你的连接字符串位于web.config或app.config,那么,

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

    您可以使用How to use the Windows Azure Blob Storage Service in .NET获得大量信息

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2011-02-07
      • 2021-12-30
      • 2014-01-23
      • 1970-01-01
      • 1970-01-01
      • 2017-03-14
      • 2013-10-04
      • 2014-02-06
      • 2019-10-31
      相关资源
      最近更新 更多