Skip to content

Commit

Permalink
added request id
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikApption committed Feb 12, 2025
1 parent 6220ed7 commit 63bf2cc
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ public async Task<IActionResult> PostCreateWorkspace()
{
// Deserialize the request body.
var body = await new StreamReader(Request.Body).ReadToEndAsync();
var savedToBlob = await SaveRequestToBlob(body);
var requestId = Guid.NewGuid().ToString();
var savedToBlob = await SaveRequestToBlob(body, requestId);

if (savedToBlob is UnauthorizedResult)
{
_logger.LogError("Failed to save request to blob storage.");
_logger.LogError($"Failed to save request to blob storage. request id {requestId}");
return savedToBlob;
}
_logger.LogInformation("Saved request to blob storage.");
Expand Down Expand Up @@ -170,15 +171,14 @@ public async Task<IActionResult> PostCreateWorkspace()
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
private async Task<IActionResult> SaveRequestToBlob(string request)
private async Task<IActionResult> SaveRequestToBlob(string request, string requestId)
{
if (_datahubPortalConfiguration?.Media?.StorageConnectionString is null)
return Unauthorized("No token available");

var blobReference = CloudStorageAccount.Parse(_datahubPortalConfiguration.Media.StorageConnectionString)
.CreateCloudBlobClient()
.GetContainerReference("hosting-requests")
.GetBlockBlobReference(Guid.NewGuid().ToString());
.GetBlockBlobReference(requestId);

await blobReference.UploadTextAsync(request);
return Ok();
Expand Down

0 comments on commit 63bf2cc

Please sign in to comment.