【问题标题】:Connection with Azure File Share using MSI not working使用 MSI 与 Azure 文件共享的连接不起作用
【发布时间】:2020-05-07 04:06:17
【问题描述】:

我正在尝试连接到 Azure 文件共享,但它引发了身份验证错误。

AzureServiceTokenProvider tokenProvider = new AzureServiceTokenProvider();
string accessToken = await tokenProvider.GetAccessTokenAsync("https://storage.azure.com/", "");

log.LogInformation(accessToken);
TokenCredential tokenCredential = new TokenCredential(accessToken);
StorageCredentials storageCredentials = new StorageCredentials(tokenCredential);

Uri fileAddress = new Uri("File URI");
CloudFile sourceFile = new CloudFile(fileAddress, storageCredentials);
log.LogInformation(await sourceFile.DownloadTextAsync());

错误:确保 Authorization 标头的值格式正确 包括签名。

同样的方法适用于 Azure Blob 存储。

我已将 Storage File Data SMB Share Contributor 角色分配给我的 Azure Function 的托管标识。

如果您需要更多信息,请告诉我。

感谢您的帮助。

【问题讨论】:

    标签: azure azure-active-directory azure-blob-storage azure-storage-files azure-managed-identity


    【解决方案1】:

    同样的方法适用于 Azure Blob 存储。

    Azure 存储不支持使用 AAD 授权文件存储。

    Azure 存储支持使用 Azure Active Directory (Azure AD) 授权对Blob and Queue storage 的请求。

    Azure 文件仅支持通过 SMB 对已加入域的 VM 使用 Azure AD 进行授权。要了解如何将 Azure AD over SMB 用于 Azure 文件,请参阅 Overview of Azure Active Directory authorization over SMB for Azure Files

    【讨论】:

    • 感谢您的解释。我已使用连接字符串连接 Azure 文件共享。
    猜你喜欢
    • 2021-12-01
    • 2014-07-11
    • 1970-01-01
    • 2021-08-24
    • 1970-01-01
    • 2018-06-22
    • 2019-06-05
    • 1970-01-01
    • 2011-11-17
    相关资源
    最近更新 更多