0

我在 Windows Azure、MVC4 上开发了一个网站。我尝试从 blob 上传和获取照片。我的相关代码(我从网络上的其他示例中获得):

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

        var blobStorage = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobStorage.GetContainerReference("abc");
        container.CreateIfNotExists();

            var permissions = container.GetPermissions();
            permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            container.SetPermissions(permissions);

我相关的 web.config 代码:

<add name="StorageConnection" connectionString="DefaultEndPointsProtocol=https;AccountName=abc;AccountKey=*******"/>

当我运行时,出现格式异常。请注意,它是网站。

根据一些帖子,当我将连接字符串放入 app.config 时,没有解决方案。

非常感谢您提供的任何帮助。

4

1 回答 1

0

You shall not use connectionStrings section to store Azure Storage Connection string! Use appSettings instead and you will have no issues. It is confusion that the Storage credentials is also named "Connection string", but it has nothing to do with the connectionStrings section in your configuration file. connectionStrings section is intended solely for use DataBase connection strings.

于 2013-01-25T07:16:59.513 回答