首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >New-AzureRmDataLakeStoreItem‘User’报头必须修改错误

New-AzureRmDataLakeStoreItem‘User’报头必须修改错误
EN

Stack Overflow用户
提问于 2019-03-29 18:24:30
回答 1查看 244关注 0票数 1

我试图使用powershell在Azure AZDataLakeStoreItem 1中创建一些新文件夹,但是和AzureRmDataLakeStoreItem都返回错误。

我对整个ADLS都有RWX权限,我有PS版本。

重大小版本修改

5 1 17134 590

当我跑的时候

代码语言:javascript
复制
Test-AzDataLakeStoreAccount -Name "weudevpocdtl" 

我得到了真正的回应。

但是,当我运行时:

代码语言:javascript
复制
New-AZDataLakeStoreItem  -Account "weudevpocdtl" -Path "/PowerShellTest" -Folder

我知道错误:

代码语言:javascript
复制
New-AZDataLakeStoreItem : Error in getting metadata for path /PowerShellTest.
Operation: GETFILESTATUS failed with   Unknown Error: The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name Source: System StackTrace:    at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName)
   at System.Net.WebHeaderCollection.Set(String name, String value)
   at Microsoft.Azure.DataLake.Store.WebTransport.AssignCommonHttpHeaders(HttpWebRequest webReq, AdlsClient client, RequestOptions req, String token, String opMethod, IDictionary`2 
customHeaders, Int32 postRequestLength)
   at Microsoft.Azure.DataLake.Store.WebTransport.<MakeSingleCallAsync>d__22.MoveNext().
.
Last encountered exception thrown after 5 tries. [The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name,The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name,The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name,The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name,The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name]
[ServerRequestId:]
At line:1 char:1
+ New-AZDataLakeStoreItem  -Account "weudevpocdtl" -Path "/PowerS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzDataLakeStoreItem], AdlsException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.NewAzureDataLakeStoreItem

当我跑的时候

代码语言:javascript
复制
New-AzureRmDataLakeStoreItem  -Account "weudevpocdtl" -Path "/PowerShellTest" -Folder

我得到了错误:

代码语言:javascript
复制
New-AzureRmDataLakeStoreItem : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 
'Microsoft.Azure.Commands.ResourceManager.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At line:1 char:1
+ New-AzureRmDataLakeStoreItem  -Account "weunappocdtl" -Path "/P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmDataLakeStoreItem], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.DataLakeStore.NewAzureDataLakeStoreItem

在另一个租户上,我曾经能够执行这些命令,而且所有这些命令都能工作。

我做错了什么?

谢谢你的帮助

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-04 09:40:17

根据Data,请参阅链接- -这是我们SDK使用的Httpwebrequest类的一个问题。在netframework和netcore之间,为httpwebrequest设置用户代理是不同的:

代码语言:javascript
复制
NET framework: webReq.UserAgent = client.GetUserAgent();

net standard webReq.Headers["User-Agent"] = client.GetUserAgent()

如果您试图在.NET框架中稍后进行操作,则会得到上面所述的错误。

当您使用这个az模块时,它使用的是我们SDK的netstandard。当您在windows中使用它时,它试图在netframework上使用.NET标准dll,从而产生此错误。

解决方案:

我在net中测试了这一点。运行的很好。我们正在从httpwebrequest转向httpclient,这可能会解决这个问题。

因此,基本上,如果您使用的是,请使用azurerm,或者使用powershell netcore中的Az。

报告了同样的错误,下面是GitHub已知问题的链接。

https://github.com/Azure/azure-powershell/issues/8141

我建议你使用Powershell核心,https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-6

它应该会起作用的。

代码语言:javascript
复制
Get-AzureRmDataLakeStoreItem -Account "AccountName" -Path "/"
New-AzureRmDataLakeStoreItem -Account "AccountName" -Path "/Staging" -Folder
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55423524

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档