Azure Data Lake Gen 2 Patch,action Flush return400 Bad Request,MissingRequiredHeader。 [英] Azure Data Lake Gen 2 Patch , action Flush return400 Bad Request, MissingRequiredHeader.
问题描述
我正在尝试从服务结构无状态/演员服务创建天蓝色数据湖Gen 2中的文件使用REST API。相同的代码适用于控制台应用程序(.NET Core作为
以及.NET Framework)。
I am trying to create files in azure data lake Gen 2 from service fabric stateless /actor service with REST API's. The same code works fine with console application (both .NET Core as well as .NET Framework).
来自Service Fabric statless或actor服务我在创建文件时得到响应System.Net.Http.NoWriteNoSeekStreamContent,做一个补丁操作。
From Service Fabric statless or actor service i get response as System.Net.Http.NoWriteNoSeekStreamContent when i create a file , do a patch operation.
补丁操作失败以进行刷新操作。
Patch Operation fails for Flush Action.
补丁码:
ublic async任务<长> UpdateFileAsync(string fileSystem,string path, byte [] dataToUpload,CancellationToken cancellationToken = default(CancellationToken))
{
long filesize = await GetFileContentLengthAsync(fileSystem,path,cancellationToken);
string uri = $" {_ fileEndpoint} / {fileSystem} / {path}?action = append& position = {使用(var httpRequestMessage = new HttpRequestMessage(new HttpMethod(" PATCH) ;),uri))
{
DLStorageRestAPIAuthHelper.SetUpHttpRequestMessage(httpRequestMessage,_storageAccountName,_storageAccountKey,dataToUpload);
var response = await SingletonClient.GetClient( URI).SendAsync(HT tpRequestMessage,cancellationToken);
CheckResponse(响应);
}
filesize + = dataToUpload.Length;
uri = $" {_ fileEndpoint} / {fileSystem} / {path}?action = flush& position = {filesize}& timeout = {timeoutDuration}" ;;
using(var httpRequestMessage = new HttpRequestMessage(new HttpMethod(" PATCH")),uri )))
{
DLStorageRestAPIAuthHelper.SetUpHttpRequestMessage(httpRequestMessage,_storageAccountName,_storageAccountKey);
var response = await SingletonClient.GetClient(httpRequestMessage.RequestUri.AbsoluteUri) .SendAsync(httpRequestMessage,cancellationToken);
CheckResponse(回复);
}
< span style ="white-space:pre"> 返回文件大小;
}
ublic async Task<long> UpdateFileAsync(string fileSystem, string path, byte[] dataToUpload, CancellationToken cancellationToken = default(CancellationToken))
{
long filesize = await GetFileContentLengthAsync(fileSystem, path, cancellationToken);
string uri = $"{_fileEndpoint}/{fileSystem}/{path}?action=append&position={filesize}&timeout={timeoutDuration}";
using (var httpRequestMessage = new HttpRequestMessage(new HttpMethod("PATCH"), uri))
{
DLStorageRestAPIAuthHelper.SetUpHttpRequestMessage(httpRequestMessage, _storageAccountName, _storageAccountKey, dataToUpload);
var response = await SingletonClient.GetClient(uri).SendAsync(httpRequestMessage, cancellationToken);
CheckResponse(response);
}
filesize += dataToUpload.Length;
uri = $"{_fileEndpoint}/{fileSystem}/{path}?action=flush&position={filesize}&timeout={timeoutDuration}";
using (var httpRequestMessage = new HttpRequestMessage(new HttpMethod("PATCH"), uri))
{
DLStorageRestAPIAuthHelper.SetUpHttpRequestMessage(httpRequestMessage, _storageAccountName, _storageAccountKey);
var response = await SingletonClient.GetClient(httpRequestMessage.RequestUri.AbsoluteUri).SendAsync(httpRequestMessage, cancellationToken);
CheckResponse(response);
}
return filesize;
}
推荐答案
嗨Santosh,
Hi Santosh,
请确保您设置了所有必需的标题。供参考:
Please make sure that you are setting all the required headers. For reference :
curl -i -X PATCH -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer
ACCESS_TOKEN" " https://
ACCESS_TOKEN" "https://
STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=flush&position=44"
STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=flush&position=44"
这篇关于Azure Data Lake Gen 2 Patch,action Flush return400 Bad Request,MissingRequiredHeader。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!