【问题标题】:How to set CORS for Azure Blob Service for Premium Storage Account in the Azure Portal?如何在 Azure 门户中为高级存储帐户的 Azure Blob 服务设置 CORS?
【发布时间】:2019-10-29 20:39:13
【问题描述】:

我创建了一个 Premium Azure Blob Storage 帐户,创建了一个 Shared Access Signature 并尝试从在 http://localhost:5001 下运行的 asp.net core Web 应用程序 html 页面上传图像。

我在门户中没有看到 CORS 部分。所以,我在 Firewalls and virtual networks 下设置了 All Networks,我认为应该允许http://localhost:5001

当我尝试向 Blob 帐户发帖时出现以下错误:

Access to XMLHttpRequest at 'https://mypictures.blob.core.windows.net/<Token>' from origin 'https://localhost:5001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

【问题讨论】:

  • answer 表示在门户的 BLOB SERVICE 下有一个 CORS 部分。但我在我的门户帐户中没有看到。
  • 快速提问:如果要上传图片,为什么要创建“高级存储帐户”?

标签: azure cors azure-blob-storage


【解决方案1】:

您收到此错误的原因是没有为您的存储帐户的 blob 服务配置 CORS。在 Azure 门户中看不到配置 CORS 的选项的原因是,Premium Storage Accounts 不支持 CORS。

来自link

您需要使用AzCopyAzure PowerShellAzure CLI、任何存储资源管理器等其他方式在高级存储帐户中上传文件,或使用任何可用的 SDK 自己编写代码。

【讨论】:

  • 我现在使用 Angular 包 @azure/storage-blob 将文件上传到非高级 Blob 存储。我可以直接从浏览器上传。即使我可以在 Asp.net 核心 Web API 中使用 SDK 调用,Premium Blob Storage 是否允许来自另一个 app 服务 端点的请求哪个托管 Asp.net 核心 Web API
  • 我不确定我是否理解这个问题。你介意再详细说明一下吗?但是,如果您只想上传图像文件(即块 blob)并希望获得高级性能,我建议您选择帐户类型为 BlockBlobStorage。具有Premium 性能级别的StorageStorageV2 类型的帐户类型仅支持用于存储虚拟机的VHD 的Page blob。
猜你喜欢
  • 2015-05-07
  • 2016-08-01
  • 2020-05-19
  • 1970-01-01
  • 2017-08-20
  • 2017-02-22
  • 2017-01-03
  • 2018-01-19
  • 2015-04-20
相关资源
最近更新 更多