简体   繁体   中英

Python: How to connect to Azure cloud storage using shared access key?

In .net I should be able to connect to the azure storage using SAS like this:

var someTable = new CloudTable("https://account-name.table.core.windows.net/table-name?sv={key}");

How can I do it in python? I could not find a CloudTable class in azure.storage.table (from azure sdk for python: https://github.com/Azure/azure-storage-python )

Is there any other way?

Try something like the following:

import os
import json
from azure import *
from azure.storage import *
from azure.storage.table import TableService, Entity

table_service = TableService(account_name='[account-name]', sas_token='[sas-token]')
list = table_service.query_entities('[table-name]', top=100)

Replace [account-name] , [sas-token] and [table-name] with actual values.

Also please do not include ? from the SAS token for the [sas-token] field.

Source: See the documentation here - https://github.com/Azure/azure-storage-python/blob/master/azure/storage/table/tableservice.py .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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