【问题标题】:Get-AzDataLakeStoreItem returns GETFILESTATUS failed with Unknown Error for valid itemsGet-AzDataLakeStoreItem 返回 GETFILESTATUS failed with Unknown Error for valid items
【发布时间】:2019-01-07 17:48:11
【问题描述】:

我正在编写一个 powershell 脚本来设置一个新的 Data Lake 存储 gen1 帐户,并使用更新的 ACL 创建文件夹。 New-AzDataLakeStoreAccount 语句工作正常; New-AzDataLakeStoreItem 和 Get-AzDataLakeStoreItem 失败并出现类似的未知错误。

以下 powershell 代码将创建一个新的 Data Lake 存储。我在订阅中有一个资源组和安全组,如下所示。用于列出和添加文件夹的第二个和第三个脚本失败。我正在使用https://shell.azure.com 执行powershell。

New-AzDataLakeStoreAccount -ResourceGroupName "ade-dev-eastus2" -Name "adedeveastus2" -Location "East US 2" -DefaultGroup (Get-AzADGroup -DisplayName "Technical Operations").Id -Encryption ServiceManaged -Tag @{User="ADE";}-Tier Consumption

Get-AzDataLakeStoreItem -AccountName "adedeveastus2" -Path "/"

New-AzDataLakeStoreItem -AccountName "adedeveastus2" -Path "/Staging" -Folder

以下是 Get-AzDataLakeStoreItem 的错误消息

Get-AzDataLakeStoreItem:获取路径 / 的元数据时出错。 操作:GETFILESTATUS 失败,出现未知错误:令牌长度为 6。令牌很可能格式错误。来源:堆栈跟踪:。 5 次尝试后抛出的最后遇到的异常。 [使用 URI 'http://localhost:50342/oauth2/token?resource=https%3A%2F%2Fdatalake.azure.net&api-version=2018-02-01' 检索资源'https://datalake.azure.net' 的托管服务访问令牌时出错。请检查此托管服务是否配置为在此地址发出令牌,并且关联的托管服务标识具有适当的角色分配并尝试再次登录。令牌长度为 6。令牌很可能格式不正确。令牌长度为 6。令牌最有可能格式错误。,令牌长度为 6。令牌最可能格式错误。,令牌长度为 6。令牌最可能格式错误。] [服务器请求ID:] 在行:1 字符:1 + 获取-AzDataLakeStoreItem -帐户“adedeveastus2”-路径“/” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzDataLakeStoreItem], AdlsException + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.GetAzureDataLakeStoreItem

使用 Windows Powershell 主机时返回的错误更具描述性。

操作:GETFILESTATUS 失败,出现未知错误:必须使用适当的属性或方法修改“User-Agent”标头。

我希望得到一个 DataLakeStoreItem 对象,以及名称和路径之类的东西。我认为 ADL 或 Cloud shell powershell 的其他用户的一般错误?

【问题讨论】:

    标签: azure powershell


    【解决方案1】:

    我可以在 Azure Cloud Shell 中重现您的问题,当我在本地 (PSVersion is 5.1.17134.228) 中运行命令时,我遇到了与 GitHub known issue 相同的错误。

    正如datalake团队所说,看到这个link

    这是我们 SDK 使用的 Httpwebrequest 类的问题。为 httpwebrequest 设置 useragent 在 netframework 和 netcore 中是不同的:

    NET 框架:webReq.UserAgent = client.GetUserAgent()

    网标:webReq.Headers["User-Agent"] = client.GetUserAgent()

    如果您稍后尝试在网络框架中进行操作,则会收到上述错误。

    当您使用这个使用我们 SDK 的 netstandard dll 的 az 模块时。当您从 windows powershell 使用它时,它会尝试在网络框架上使用网络标准 dll,这会产生此错误。

    以及解决方案

    我在 net core powershell 中对此进行了测试。它运行良好。 我们正在从 httpwebrequest 迁移到 httpclient,这可能会解决这个问题。

    所以基本上,如果您使用的是 windows powershell,请使用 azurerm 或使用 powershell netcore 中的 Az。

    它似乎解释了错误The 'User-Agent' header must be modified using the appropriate property or method,因此您可以尝试在Powershell core 中使用Az powershell。如果可以接受,你也可以在windows powershell中使用AzureRM powershell模块,对我来说效果很好。

    Get-AzureRmDataLakeStoreItem -Account "joydatalake2" -Path "/"
    New-AzureRmDataLakeStoreItem -Account "joydatalake2" -Path "/Staging" -Folder
    

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 2021-07-10
      • 1970-01-01
      • 2021-11-28
      • 2022-12-19
      • 2012-07-28
      • 1970-01-01
      • 2023-01-21
      • 2020-11-06
      相关资源
      最近更新 更多