简体   繁体   English

如何通过python SDK设置Azure表的属性

[英]How to set the properties of an Azure Table through python sdk

I am trying to enable CORS for a specific azure account/table from the python sdk. 我正在尝试从python sdk为特定的azure帐户/表启用CORS。

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. 这里我知道我必须使用set_table_service_properties()并传递storage_service_properties参数。 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转换后会产生类似的东西吗?

<?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. 不久将在下一版本的Python库中修复此问题(即将发布,请参阅dev分支),但是此库目前不支持设置CORS。

In the new version, it will be settable something like this sample shows. 在新版本中,将可以设置此示例所示的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM