Azure ADLS - Python 内的 azcopy 复制
我无权获取容器的访问密钥。因此无法使用“azure.storage.blob import BlobServiceClient”。我只能使用使用 SAS 密钥的 ContainerClient 类。
我可以在 Windows 计算机的命令提示符下使用“azure azcopy”复制包括子文件夹在内的数据。 子文件夹:456 并使用以下命令将数据复制到目标 adls 容器。
azcopy 复制“https://[account].blob.core.windows.net/[source_container]/abc/def/123/tst/456?[SAS]”“https://[account].blob.core。 windows.net/[target_container]/tgttst?[SAS]"
请让我知道如何自动在目标 ADLS 上创建子文件夹并在 Python 脚本内复制数据。
提前致谢。
收到错误消息“属性错误:‘BlobClient’对象没有属性 create_container”
from azure.storage.blob import ContainerClient
sas_url="[account].blob.core.windows.net/[target_container]/tgttst?[SAS]"
container=ContainerClient.from_container_url(sas_url)
container_client = container.get_blob_client("abc/def/123")
container_client.create_container()
注意:SAS 令牌具有读/写/列表权限
I don't have permission to get access keys for containers.Due to this unable to use "azure.storage.blob import BlobServiceClient".I can use only ContainerClient class using SAS key.
I can copy data including subfolder using "azure azcopy" on the command prompt from a windows machine.
subfolder:456 and data copied to target adls container using below command.
azcopy copy "https://[account].blob.core.windows.net/[source_container]/abc/def/123/tst/456?[SAS]" "https://[account].blob.core.windows.net/[target_container]/tgttst?[SAS]"
Please let me know how to automate to create subfolder on target ADLS and to copy data inside Python script.
Thanks in advance.
getting an error message "Attribute Error: 'BlobClient' object has no attribute create_container"
from azure.storage.blob import ContainerClient
sas_url="[account].blob.core.windows.net/[target_container]/tgttst?[SAS]"
container=ContainerClient.from_container_url(sas_url)
container_client = container.get_blob_client("abc/def/123")
container_client.create_container()
Note : SAS token has READ/WRITE/LIST privileges
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经找到解决办法了,感谢您的帮助:
I have found the solution, thanks for your help: