gpt4 book ai didi

c# - Azure Datalake 操作返回无效状态代码禁止

转载 作者:太空宇宙 更新时间:2023-11-03 12:14:26 25 4
gpt4 key购买 nike

我正在向 Azure Datalake 写入一个简单的文件,以了解如何将其用于其他方式,但我遇到了问题,当我尝试写入时,收到以下错误消息

21/5/2018 9:03:27 AM] Executed 'NWPimFeederFromAws' (Failed, Id=39adba4b-9c27-4078-b560-c25532e8432e)
[21/5/2018 9:03:27 AM] System.Private.CoreLib: Exception while executing function: NWPimFeederFromAws. Microsoft.Azure.Management.DataLake.Store: One or more errors occurred. (Operation returned an invalid status code 'Forbidden'). Microsoft.Azure.Management.DataLake.Store: Operation returned an invalid status code 'Forbidden'.

有问题的代码如下

static void WriteToAzureDataLake() {

// 1. Set Synchronization Context
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

// 2. Create credentials to authenticate requests as an Active Directory application
var clientCredential = new ClientCredential(clientId, clientSecret);

//var creds = ApplicationTokenProvider.LoginSilentAsync(tenantId, clientCredential).Result;
var creds = ApplicationTokenProvider.LoginSilentAsync(tenantId, clientCredential).Result;

// 2. Initialise Data Lake Store File System Client
adlsFileSystemClient = new DataLakeStoreFileSystemManagementClient(creds);

// 3. Upload a file to the Data Lake Store
var source = "c:\\nwsys\\source.txt";
var destination = "/PIMRAW/destination.txt";
adlsFileSystemClient.FileSystem.UploadFile(adlsAccountName, source, destination, 1, false, true);

// FINISHED
Console.WriteLine("6. Finished!");
}

我已将应用程序从 Azure AD 添加到我尝试写入的特定文件夹的访问列表中,如下所示

Azure portal showing the correct rights

我的代码中的 clientID 和 clientSecret 来自这个应用程序,所以我有点不明白为什么我被禁止。

我还忘记了什么吗?

在我尝试创建客户端之前,loginAsync 是否尚未完成?

最佳答案

您是否授予应用程序/服务主体对应用程序正在写入的特定文件夹的路径中的父文件夹的执行访问权限?这是遍历文件夹路径所必需的,请参阅此处的一些示例:https://learn.microsoft.com/en-us/azure/data-lake-store/data-lake-store-access-control#common-scenarios-related-to-permissions

关于c# - Azure Datalake 操作返回无效状态代码禁止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50445921/

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