如何设置一个Azure Table中,通过蟒蛇SDK属性 [英] How to set the properties of an Azure Table through python sdk

查看:302
本文介绍了如何设置一个Azure Table中,通过蟒蛇SDK属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使CORS可以从Python SDK特定的蔚蓝帐户/表。

不幸的是,文档不涉及该主题。从寻找 我知道我必须使用 set_table_service_properties()并通过 storage_service_properties 参数。但我不知道这是怎么说法应该被格式化。

我应该创建一个字典,当传递给转换将产生类似的XML?

 <?XML版本=1.0编码=UTF-8&GT?;
< StorageServiceProperties>
    <采伐>
        <版本> 1.0 LT; /版本>
        <删除>真< /删除>
        <读取>假LT; /读取和GT;
        <写>真< /写>
        <&的RetentionPolicy GT;
            <&启用GT;真< /启用>
            <天> 7 LT; /天>
        < /&的RetentionPolicy GT;
    < /记录>
    < HourMetrics>
        <版本> 1.0 LT; /版本>
        <&启用GT;真< /启用>
        < IncludeAPIs>假LT; / IncludeAPIs>
        <&的RetentionPolicy GT;
            <&启用GT;真< /启用>
            <天> 7 LT; /天>
        < /&的RetentionPolicy GT;
    < / HourMetrics>
    < MinuteMetrics>
        <版本> 1.0 LT; /版本>
        <&启用GT;真< /启用>
        < IncludeAPIs>真< / IncludeAPIs>
        <&的RetentionPolicy GT;
            <&启用GT;真< /启用>
            <天> 7 LT; /天>
        < /&的RetentionPolicy GT;
    < / MinuteMetrics>
    <一个Cors>
        < CorsRule>
            &LT; AllowedOrigins&GT; HTTP://www.fabrikam.com,http://www.contoso.com< / AllowedOrigins&GT;
            &LT; AllowedMethods&GT; GET,PUT&LT; / AllowedMethods&GT;
            &所述; MaxAgeInSeconds&GT; 500℃; / MaxAgeInSeconds&GT;
            &LT; ExposedHeaders&GT; X-MS-元数据*,X-MS-元customheader&LT; / ExposedHeaders&GT;
            &LT; AllowedHeaders&GT; X-MS-元目标*,X-MS-元customheader&LT; / AllowedHeaders&GT;
        &LT; / CorsRule&GT;
    &LT; /一个Cors&GT;
&LT; / StorageServiceProperties&GT;


解决方案

这是不久将被固定在的下一个版本 Python库的(将很快公布,请参阅Dev分支),但此刻的库不支持设置CORS。

在新的版本,这将是硬性类似此示例节目。

I am trying to enable CORS for a specific azure account/table from the python sdk.

Unfortunately the docs do not cover that topic. From looking here I know that I must use the set_table_service_properties() and pass the storage_service_properties argument. But I don't know how is this argument supposed to be formatted.

Should I create a dictionary that when passed to the xml converted will produce something like that?

<?xml version="1.0" encoding="utf-8"?>
<StorageServiceProperties>
    <Logging>
        <Version>1.0</Version>
        <Delete>true</Delete>
        <Read>false</Read>
        <Write>true</Write>
        <RetentionPolicy>
            <Enabled>true</Enabled>
            <Days>7</Days>
        </RetentionPolicy>
    </Logging>
    <HourMetrics>
        <Version>1.0</Version>
        <Enabled>true</Enabled>
        <IncludeAPIs>false</IncludeAPIs>
        <RetentionPolicy>
            <Enabled>true</Enabled>
            <Days>7</Days>
        </RetentionPolicy>
    </HourMetrics>
    <MinuteMetrics>
        <Version>1.0</Version>
        <Enabled>true</Enabled>
        <IncludeAPIs>true</IncludeAPIs>
        <RetentionPolicy>
            <Enabled>true</Enabled>
            <Days>7</Days>
        </RetentionPolicy>
    </MinuteMetrics>
    <Cors>
        <CorsRule>
            <AllowedOrigins> http://www.fabrikam.com,http://www.contoso.com</AllowedOrigins>
            <AllowedMethods>GET,PUT</AllowedMethods>
            <MaxAgeInSeconds>500</MaxAgeInSeconds>
            <ExposedHeaders>x-ms-meta-data*,x-ms-meta-customheader</ExposedHeaders>
            <AllowedHeaders>x-ms-meta-target*,x-ms-meta-customheader</AllowedHeaders>
        </CorsRule>
    </Cors>
</StorageServiceProperties>

解决方案

This is shortly going to be fixed in the next version of the Python library (to be released very soon, see the dev branch), but at the moment the library doesn't support setting CORS.

In the new version, it will be settable something like this sample shows.

这篇关于如何设置一个Azure Table中,通过蟒蛇SDK属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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