SAS URL 看起来像这样: https://<container_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D
#pip3 install azure-storage-blobfrom azure.storage.blob import BlobServiceClient# List containersconn_str="<SAS URL>"svc = BlobServiceClient.from_connection_string(conn_str=conn_str)for c in svc.list_containers():print(c['name'])# List blobs inside the containerscontainer = svc.get_container_client(container=c['name'])for b in container.list_blobs():print(b['name'])# Download all the blobsblob_name = b['name'].split("/")[::-1][0]blob = svc.get_blob_client(container=c['name'],blob=b['name'])withopen(blob_name,"wb")as f:f.write(blob.download_blob().readall())
委托访问当前不通过服务特定 SAS 提供的服务级操作,例如 Get/Set Service Properties 和 Get Service Stats 操作。
同时委托对存储帐户中多个服务的访问。例如,您可以通过使用帐户 SAS 委托对 Azure Blob Storage 和 Azure Files 中资源的访问。
委托对容器、队列、表和文件共享的写入和删除操作的访问,这些操作在对象特定 SAS 中不可用。
指定接受请求的 IP 地址或 IP 地址范围。
指定接受请求的 HTTP 协议(HTTPS 或 HTTP/HTTPS)。
枚举
# Get storage accountsazstorageaccountlist#Get the account name from here# Get keys to authenticateazstorageaccountkeyslist--account-name<name># Get sharesazstoragesharelist--account-name<name>--account-key<key># Get dirs/files inside the shareazstoragefilelist--account-name<name>--share-name<share-name>--account-key<key>## If type is "dir", you can continue enumerationg files inside of itazstoragefilelist--account-name<name>--share-name<prev_dir/share-name>--account-key<key># Download a complete share (with directories and files inside of them)azstoragefiledownload-batch-d.--source<share-name>--account-name<name>--account-key<key>
# Get storage accountsGet-AzStorageAccount| fl# Get rules to access the storage accountGet-AzStorageAccount| select -ExpandProperty NetworkRuleSet# Get IPs(Get-AzStorageAccount| select -ExpandProperty NetworkRuleSet).IPRules# Get containers of a storage accountGet-AzStorageContainer-Context (Get-AzStorageAccount-name <NAME>-ResourceGroupName <NAME>).context# Get blobs inside containerGet-AzStorageBlob -Container epbackup-planetary -Context (Get-AzStorageAccount -name <name> -ResourceGroupName <name>).context
# Get a blob from a containerGet-AzStorageBlobContent -Container <NAME> -Context (Get-AzStorageAccount -name <NAME> -ResourceGroupName <NAME>).context -Blob <blob_name> -Destination .\Desktop\filename.txt