如何使用HTTP将CORS规则添加到Azure存储模拟器? [英] How do i add a CORS rule to the Azure Storage Emulator with HTTP?

查看:69
本文介绍了如何使用HTTP将CORS规则添加到Azure存储模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用Azure存储(仿真器)表服务,我需要为TypeScript浏览器应用程序添加CORS规则.

To use the Azure Storage (Emulator) Table Service, i need to add a CORS rule for my TypeScript Browser App.

我想使用REST界面手动添加该规则(来自Postman,而不是具有相同原始策略的浏览器). 该文档没有为模拟器提供正确的URL( https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/insert-entity ).

I want to add that rule manually using the REST interface (from Postman, not the Browser with the Same Origin Policy). The documentation does not give the correct URL for the Emulator (https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-table-service-properties). For DML commands it is like in my request (https://docs.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>

什么是正确的URL或我在做什么错?

What is the correct URL or what am i doing wrong?

推荐答案

如果下载

If you download the Microsoft Azure Storage Explorer, you can set it up by right clicking on "Blob Containers" under your account.

这篇关于如何使用HTTP将CORS规则添加到Azure存储模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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