gpt4 book ai didi

c# - 尝试使用托管访问连接 Azure DataLake 但出现未经授权的错误

转载 作者:行者123 更新时间:2023-12-03 03:47:42 27 4
gpt4 key购买 nike

string dfsUri = "https://" + accountName + ".dfs.core.windows.net";
DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient(new Uri(dfsUri), new DefaultAzureCredential(new DefaultAzureCredentialOptions()));
DataLakeFileSystemClient dataLakeFileSystemClient = await dataLakeServiceClient.CreateFileSystemAsync("test1");
DataLakeDirectoryClient directoryClient = await dataLakeFileSystemClient.CreateDirectoryAsync("my-directory");
DataLakeFileClient fileClient = await directoryClient.CreateFileAsync("uploaded-file.txt");
FileStream fileStream = File.OpenRead("");
long fileSize = fileStream.Length;
await fileClient.AppendAsync(fileStream, offset: 0);
await fileClient.FlushAsync(position: fileSize);

尝试使用托管身份连接 Azure DataLake,但在线出现未经授权的错误:

DataLakeFileSystemClient dataLakeFileSystemClient = await dataLakeServiceClient.CreateFileSystemAsync("test1");

error message : This request is not authorized to perform this operation , Status: 403 (This request is not authorized to perform this operation.)\r\nErrorCode: AuthorizationFailure

最佳答案

确保您的托管身份至少具有存储数据 blob 读取器或存储数据 blob 贡献者角色。

要了解使用 Azure 门户分配对资源的托管标识访问权限,请检查以下链接:Assign a managed identity access to a resource by using the Azure portal

要了解 Ask gen2 中可用角色的详细信息,请查看以下链接:Access control model in Azure Data Lake Storage Gen2

您能否告诉我们,您为托管身份授予了哪些角色?

关于c# - 尝试使用托管访问连接 Azure DataLake 但出现未经授权的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68488681/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com