azure - 如何使用 HTTP 将 CORS 规则添加到 Azure 存储模拟器?

标签 azure cors azure-storage azure-table-storage azure-storage-emulator

要使用 Azure 存储(模拟器)表服务,我需要为我的 TypeScript 浏览器应用添加 CORS 规则。

我想使用 REST 接口(interface)(来自 Postman,而不是具有同源策略的浏览器)手动添加该规则。 该文档没有提供模拟器的正确 URL ( https://learn.microsoft.com/en-us/rest/api/storageservices/fileservices/set-table-service-properties )。 对于 DML 命令,就像我的请求 (https://learn.microsoft.com/en-us/rest/api/storageservices/fileservices/insert-entity)。

请求是:

PUT /devstoreaccount1/?restype=service&comp=properties HTTP/1.1
Host: 127.0.0.1:10002
x-ms-version: 2013-08-15
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: 280f880b-d6df-bb1d-bc12-eca411e18310

<StorageServiceProperties>
    <Cors>
        <CorsRule>
            <AllowedOrigins>http://localhost:3030</AllowedOrigins>
            <AllowedMethods>GET,PUT,POST</AllowedMethods>
            <MaxAgeInSeconds>500</MaxAgeInSeconds>
            <ExposedHeaders>x-ms-meta-data*,x-ms-meta-target*,x-ms-meta-abc</ExposedHeaders>
            <AllowedHeaders>x-ms-meta-*</AllowedHeaders>
        </CorsRule>
    </Cors>
</StorageServiceProperties>

结果是:

<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <m:code>ResourceNotFound</m:code>
    <m:message xml:lang="en-US">The specified resource does not exist.
RequestId:8137042f-0402-46c6-aa8c-fbf9f4601d33
Time:2017-01-15T09:13:51.7500394Z</m:message>
</m:error>

正确的网址是什么,或者我做错了什么?

最佳答案

如果您下载 Microsoft Azure Storage Explorer ,您可以通过右键单击您帐户下的“Blob 容器”来进行设置。

enter image description here

关于azure - 如何使用 HTTP 将 CORS 规则添加到 Azure 存储模拟器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41659780/

相关文章:

azure - 无法连接到 Ubuntu 12.04 Microsoft Azure 实例

azure - Azure 中的 SQL 始终加密

node.js - Node express 公司和路线

c# - Azure Blob 容器线程安全吗?

azure - 无法在 Windows VM 上使用 terraform 和 Azure VM 扩展自动映射 azure 存储共享

azure - 如何使用azure逻辑应用程序在azure数据湖中上传文件

Azure 文件在 kubernetes 中授予权限被拒绝

angularjs - 跨源请求被阻止,AngularJS 对 jersey api 的剩余调用

javascript - 如何允许 ASP.NET 使用 CORS

azure - 创建 StorageManagementClient 和 EventGridManagementClient 时如何使用 VisualStudioCredential