Azure CloudBlobContainer.CreateIfNotExists()在本地开发上抛出禁止(403) [英] Azure CloudBlobContainer.CreateIfNotExists() throws Forbidden (403) on Local Development

查看:208
本文介绍了Azure CloudBlobContainer.CreateIfNotExists()在本地开发上抛出禁止(403)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始在blobContainer.createIfNotExists上收到403错误.以下是源代码.

I've started getting 403 Error on blobContainer.createIfNotExists. Following is the source code.

 CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        string blobContainerName =string.IsNullOrEmpty(_sessionContext.DomainName) ? "localdevblob": _sessionContext.DomainName.ToLower();
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference(blobContainerName);
        container.CreateIfNotExists();

已验证的事情:

  • 容器名称是小写&确认标准
  • 可以在Storage Explorer中访问本地Blob存储,并且可以在读取/上传内容中正常工作
  • 连接字符串为: add key ="StorageConnectionString" value ="UseDevelopmentStorage = true"
  • container name is lower case & confirms to the standard
  • the local blob storage is accessible in the Storage Explorer and works fine in reading / uploading content
  • connection string is: add key="StorageConnectionString" value="UseDevelopmentStorage=true"

预计升级库可能会解决此问题:

Anticipating that upgrading the library might fix the issue:

  • 将存储模拟器升级到5.2
  • 将Nuget软件包WindowsAzure.Storage升级到8.4.0(之前是8.1.0,但已经给出了错误)

异常屏幕截图如下:

更新

显然,我只是从 https:/下载的示例/github.com/Azure-Samples/storage-blob-dotnet-getting-started.git ,它也可以工作.当我将我的项目和示例项目中的cloudBlobClient对象进行比较时,我发现由于某种奇怪的原因,我发现blobClient(在我的项目中)缺少"AuthenticationHandler"和"Key",这将导致问题.但是,这两个值存在于示例项目中.

Apparently, i just downloaded the sample from https://github.com/Azure-Samples/storage-blob-dotnet-getting-started.git and that works too. and when i compared the cloudBlobClient object in my project and the sample project i found that for some strange reason I found that blobClient (in my project) is missing "AuthenticationHandler" and the "Key" which would be causing the issue. But these 2 values are present in the sample project.

推荐答案

在blobContainer.createIfNotExists上获得403错误

getting 403 Error on blobContainer.createIfNotExists

我创建了一个示例来重现我的问题,将WindowsAzure.Storage sdk v8.1.0 安装到 v8.1.4 v8时,代码可以正常工作.4.0 .

I created a sample to reproduce the issue on my side, the code works fine with installing WindowsAzure.Storage sdk v8.1.0 to v8.1.4 and v8.4.0.

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

container.CreateIfNotExists();

我还使用WindowsAzure.Storage v7.0.0测试了代码,它也可以工作.

And I also test the code with WindowsAzure.Storage v7.0.0, it works too.

此外,一些社区成员报告说,如果在项目中安装了 ApplicationInsights ,则在执行存储操作时WindowsAzure.Storage sdk返回403错误,此

Besides, some community members report that the WindowsAzure.Storage sdk returns 403 error when do storage operations if ApplicationInsights is installed in project, this SO thread discussed it.

这篇关于Azure CloudBlobContainer.CreateIfNotExists()在本地开发上抛出禁止(403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆