无法通过服务结构在DataLake Gen2上进行补丁操作 [英] Unable to make Patch operation on DataLake Gen2 through service fabric

查看:84
本文介绍了无法通过服务结构在DataLake Gen2上进行补丁操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过HttpClient从Service Fabric应用程序调用DataLake Gen 2,因为还没有实现SDK。

I am trying to call DataLake Gen 2 through HttpClient from Service Fabric Application, Since there is no SDK yet implemented.

我无法从Service Fabric应用程序进行补丁操作。

I am unable to make patch operation from Service fabric application.

datalake2上的Create操作通过状态码为202的RestAPI工作,但内容为:System.Net.Http。 NoWriteNoSeekStreamContent

The Create operation on datalake2 works through RestAPI with a statuscode 202, but with Content: System.Net.Http.NoWriteNoSeekStreamContent

在补丁操作中,其余调用返回400状态代码,其中包含  内容:System.Net.Http.NoWriteNoSeekStreamContent

On Patch operation the rest call returns 400 statuscode with Content: System.Net.Http.NoWriteNoSeekStreamContent

我设置了所有必填标题。 

I have set all the mandatory headers. 

x-ms-date,
x-ms-version,
授权,Content-len gth

下面的代码用于在datalake2中创建文件,

The code below is for creating file in datalake2,

public async任务CreateFileSystemAsync(string fileSystem,CancellationToken cancellationToken = default( CancellationToken)))
{

string uri = $" {_ fileEndpoint} / {_ fileSystem}?resource = filesystem& timeout = {timeoutDuration}"; $
using(var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put,uri))

{

SetUpHttpRequestMessage(httpRequestMessage);

HttpResponseMessage response = await httpClient .SendAsync(httpRequestMessage,cancellationToken);

CheckResponse(响应);

}

}

public async Task CreateFileSystemAsync(string fileSystem, CancellationToken cancellationToken = default(CancellationToken))
{
string uri = $"{_fileEndpoint}/{_fileSystem}?resource=filesystem&timeout={timeoutDuration}";
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, uri))
{
SetUpHttpRequestMessage(httpRequestMessage);
HttpResponseMessage response = await httpClient.SendAsync(httpRequestMessage, cancellationToken);
CheckResponse(response);
}
}

返回: 

{StatusCode:202,ReasonPhrase:'Accepted',Version:1.1,Content:System.Net.Http.NoWriteNoSeekStreamContent,Headers:

{

 日期:2019年5月31日星期五17:34:26 GMT

 服务器:Windows-Azure-HDFS / 1.0

 服务器:Microsoft-HTTPAPI / 2.0

  x-ms-request-server-encrypted:true

  x-ms-request-id:87785c96-701f-0004-0dd7-17ff98000000

  x-ms-version:2018-11-09

 内容长度:0

  Content-MD5:7Qwq3R83Z / LbKRCHbzrTPQ ==

}}

{StatusCode: 202, ReasonPhrase: 'Accepted', Version: 1.1, Content: System.Net.Http.NoWriteNoSeekStreamContent, Headers:
{
  Date: Fri, 31 May 2019 17:34:26 GMT
  Server: Windows-Azure-HDFS/1.0
  Server: Microsoft-HTTPAPI/2.0
  x-ms-request-server-encrypted: true
  x-ms-request-id: 87785c96-701f-0004-0dd7-17ff98000000
  x-ms-version: 2018-11-09
  Content-Length: 0
  Content-MD5: 7Qwq3R83Z/LbKRCHbzrTPQ==
}}

以下代码用于补丁操作,返回400状态码,

Below code is for Patch operation which returns 400 status code,

字符串uri = $" {_ fileEndpoint} / {_ fileSystem} / {path}?action = append& position = {position}& timeout = {timeoutDuration}" ; $
using(var httpRequestMessage = new HttpRequestMessage(new HttpMethod(" PATCH"),uri))

{

SetUpHttpRequestMessage(httpRequestMessage,dataToUpload) ;
$
var response = await httpClient.SendAsync(httpRequestMessage,cancellationToken);

CheckResponse(响应);

}

string uri = $"{_fileEndpoint}/{_fileSystem}/{path}?action=append&position={position}&timeout={timeoutDuration}";
using (var httpRequestMessage = new HttpRequestMessage(new HttpMethod("PATCH"), uri))
{
SetUpHttpRequestMessage(httpRequestMessage,dataToUpload);
var response = await httpClient.SendAsync(httpRequestMessage, cancellationToken);
CheckResponse(response);
}

返回: 

{StatusCode:400,ReasonPhrase:'未指定此请求必需的HTTP标头。',版本:1.1,Conten t:System.Net.Http.NoWriteNoSeekStreamContent,Headers:

{

 日期:2019年5月31日星期五17:40:51 GMT

 服务器:Windows-Azure-HDFS / 1.0

 服务器:Microsoft-HTTPAPI / 2.0

  x-ms-error-code:MissingRequiredHeader

  x-ms-request-id:ef7fd05b-d01f-0046-47d7-17d48c000000

  x-ms-version:2018-11-09

 内容长度:204

  Content-Type:application / json; charset = utf-8

}}

{StatusCode: 400, ReasonPhrase: 'An HTTP header that's mandatory for this request is not specified.', Version: 1.1, Content: System.Net.Http.NoWriteNoSeekStreamContent, Headers:
{
  Date: Fri, 31 May 2019 17:40:51 GMT
  Server: Windows-Azure-HDFS/1.0
  Server: Microsoft-HTTPAPI/2.0
  x-ms-error-code: MissingRequiredHeader
  x-ms-request-id: ef7fd05b-d01f-0046-47d7-17d48c000000
  x-ms-version: 2018-11-09
  Content-Length: 204
  Content-Type: application/json; charset=utf-8
}}

我将授权设置如下:

我在dotnet框架项目中尝试了相同的代码,它完全正常。在所有非服务面料项目中都可以使用它也很好。

I have tried the same code in a dotnet framework project which works absolutely fine. Tried in all non service fabric project which works fine too.

我相信它似乎是Service Fabric的一个问题。

Its seems to be a problem with Service Fabric i believe.

谢谢

Suraj

+919686789788

+919686789788

suraj.nd@hotmail.com

suraj.nd@hotmail.com

推荐答案

Hi Suraj,

Hi Suraj,

详情请参阅以下内容:

写入文件:
$


以下命令将文本添加到file1的开头。



printf'数据行1 \数据行2 \''| curl -i -X PATCH -H" x-ms-version:2018-11-09" -H"授权:承载

To Write to a file :

The following command adds text to the beginning of file1.

printf 'data row 1\ndata row 2\n' | curl -i -X PATCH -H "x-ms-version: 2018-11-09" -H "Authorization: Bearer


ACCESS_TOKEN" --data-binary @ - " https://
ACCESS_TOKEN" --data-binary @- "https://


STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=append&position=0"



完成后,服务器返回202 Accepted响应。



现有数据已存在于file1中,以下内容如下命令将数据附加到现有值。



printf'数据行3 \数据行4 \ n'| curl -i -X PATCH -H" x-ms-version:2018-11-09" -H"授权:持票人
STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=append&position=0"

Once complete, the server returns a 202 Accepted response.

With existing data already in file1, the following command appends data to the existing value.

printf 'data row 3\ndata row 4\n' | curl -i -X PATCH -H "x-ms-version: 2018-11-09" -H "Authorization: Bearer


这篇关于无法通过服务结构在DataLake Gen2上进行补丁操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆