admin管理员组文章数量:1344206
I have a SubOrchestrator function that calls the following Activity Functions:
public async Task GetTransitiveMembers(IDurableOrchestrationContext context, GroupMembershipRequest request)
{
if (!context.IsReplaying) _ = _log.LogMessageAsync(new LogMessage { RunId = request.RunId, Message = $"Getting results from 1st page" });
var nextPageUrl = await context.CallActivityAsync<string>(nameof(MembersReaderFunction), new MembersReaderRequest { RunId = request.RunId, GroupId = request.SourceGroup.ObjectId, TargetGroupId = request.GroupId, CurrentPart = request.CurrentPart });
while (!string.IsNullOrEmpty(nextPageUrl))
{
if (!context.IsReplaying) _ = _log.LogMessageAsync(new LogMessage { RunId = request.RunId, Message = $"Getting results from next page url: {nextPageUrl}" });
var oldNextPageUrl = nextPageUrl;
nextPageUrl = await context.CallActivityAsync<string>(nameof(SubsequentMembersReaderFunction), new SubsequentMembersReaderRequest { RunId = request.RunId, NextPageUrl = nextPageUrl, GroupId = request.SourceGroup.ObjectId, TargetGroupId = request.GroupId, CurrentPart = request.CurrentPart })
}
}
Activity functions:
[FunctionName(nameof(MembersReaderFunction))]
public async Task<string> GetMembersAsync([ActivityTrigger] MembersReaderRequest request)
{
await _log.LogMessageAsync(new LogMessage { Message = $"{nameof(MembersReaderFunction)} function started", RunId = request.RunId }, VerbosityLevel.DEBUG);
_calculator.RunId = request.RunId;
var response = await _calculator.GetFirstTransitiveMembersPageAsync(request.GroupId, request.RunId);
response.Users = new List<AzureADUser> { new AzureADUser { UserPrincipalName = "a" } };
var fileName = $"/{request.TargetGroupId}/{request.RunId}_GroupMembership_{request.CurrentPart}.json";
using (MemoryStream logEntryStream = new MemoryStream())
{
await JsonSerializer.SerializeAsync(logEntryStream, response.Users);
logEntryStream.Position = 0;
await _blobStorageRepository.AppendDataToBlobAsync(logEntryStream, fileName);
}
await _log.LogMessageAsync(new LogMessage { Message = $"{nameof(MembersReaderFunction)} function completed", RunId = request.RunId }, VerbosityLevel.DEBUG);
return response.NextPageUrl;
}
[FunctionName(nameof(SubsequentMembersReaderFunction))]
public async Task<string> GetMembersAsync([ActivityTrigger] SubsequentMembersReaderRequest request)
{
await _log.LogMessageAsync(new LogMessage { Message = $"{nameof(SubsequentMembersReaderFunction)} function started", RunId = request.RunId }, VerbosityLevel.DEBUG);
_calculator.RunId = request.RunId;
var response = await _calculator.GetNextTransitiveMembersPageAsync(request.NextPageUrl);
response.Users = new List<AzureADUser> { new AzureADUser { UserPrincipalName = "b" } };
var fileName = $"/{request.TargetGroupId}/{request.RunId}_GroupMembership_{request.CurrentPart}.json";
using (MemoryStream logEntryStream = new MemoryStream())
{
await JsonSerializer.SerializeAsync(logEntryStream, response.Users);
logEntryStream.Position = 0;
await _blobStorageRepository.AppendDataToBlobAsync(logEntryStream, fileName);
}
await _log.LogMessageAsync(new LogMessage { Message = $"{nameof(SubsequentMembersReaderFunction)} function completed", RunId = request.RunId }, VerbosityLevel.DEBUG);
return response.NextPageUrl;
}
BlobStorageRepository:
public async Task AppendDataToBlobAsync (MemoryStream logEntryStream, string logBlobName)
{
var appendBlobClient = _containerClient.GetAppendBlobClient(logBlobName);
await appendBlobClient.CreateIfNotExistsAsync();
logEntryStream.Position = 0;
var maxBlockSize = appendBlobClient.AppendBlobMaxAppendBlockBytes;
var bytesLeft = logEntryStream.Length;
var buffer = new byte[maxBlockSize];
while (bytesLeft > 0)
{
var blockSize = (int)Math.Min(bytesLeft, maxBlockSize);
var bytesRead = await logEntryStream.ReadAsync(buffer.AsMemory(0, blockSize));
await using (MemoryStream memoryStream = new MemoryStream(buffer, 0, bytesRead))
{
await appendBlobClient.AppendBlockAsync(memoryStream);
}
bytesLeft -= bytesRead;
}
}
I see the content in blob like this:
[
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "a",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
}
][
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "b",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
}
][
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "b",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
}
]
It should be:
[
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "a",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
},
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "b",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
},
{
"ObjectId": "00000000-0000-0000-0000-000000000000",
"Mail": null,
"UserPrincipalName": "b",
"Properties": null,
"MembershipAction": null,
"SourceGroup": "00000000-0000-0000-0000-000000000000",
"SourceGroups": null
}
] How do I fix this?
本文标签: blobstorageappend blob with NET appending data to separate arraysStack Overflow
版权声明:本文标题:blobstorage - append blob with .NET appending data to separate arrays - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743741227a2530929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论