Azure Python SDK-验证到斑点存储
我想使用Python SDK操纵(删除)用ADL(容器)中的文件和文件夹来操纵(删除)。我有2个问题:
- 用于此目的的数百个Azure SDK中的哪个?
- 如何使用AAD代币进行身份验证?我真的更喜欢以这种方式进行身份验证,或者也使用凭据来委托(用户名,密码,租户)
我已经看过:
- azure.storage.filedatalake
- azure.storage.storage.storage.storage.storage.blob
和使用
- azure.Identities.Identientientientiention.tokencredentials,tokencrecredentials,azurecrecrecrecrecrecrecrecrecredentials
I would like to manipulate (delete) with files and folders in my ADLS (container) using Python SDK. I have 2 issues:
- Which of the hundreds of Azure SDKs to use for this purpose?
- How to authenticate using AAD token? I really prefer authenticating this way, or also using credentials for service principal (username, password, tenant)
I already looked at:
- azure.storage.filedatalake
- azure.storage.blob
and authentication using
- azure.identity - TokenCredentials, AzureCliCredential
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑到ADLS Gen2是在Blob存储顶部构建的,您可以同时使用
azure.storake.filedatalake
或azure.storage.storage.storage.blob
,但是建议是使用> azure.storage.filedatalake
由于该SDK是为ADLS Gen2设计的。请参考 <<<<<<<<<<代码>使用Azure Active Directory 授权访问BLOB,涉及如何使用Azure AD连接到Azure存储。这里要记住的关键是,任何用户(甚至服务原理)都使用Azure AD凭据连接到Azure Storage,都必须分配用户Azure Storage数据操作权限,例如BLOB数据贡献者。
完成此操作后,只需创建一个凭据对象,然后使用该凭据对象连接到Azure存储。
例如,查看下面的代码示例,该示例取自
此处 :
Considering ADLS Gen2 is built on top of Blob Storage, you can use both
azure.storage.filedatalake
orazure.storage.blob
however the recommendation would be to useazure.storage.filedatalake
as this SDK is designed for ADLS Gen2.Please refer to
Authorize access to blobs using Azure Active Directory
regarding how to connect to Azure Storage using Azure AD. The key thing to remember here is that whatever user (even Service Principal) is connecting to Azure Storage using Azure AD credentials, that user must be assigned Azure Storage Data Operations permissions e.g. Blob Data Contributor.Once you have done that, simply create a credential object and then use that credential object to connect to Azure Storage.
For example, take a look at the code sample below which is taken from
here
: