diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24d07ec..8f4f9c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: if: (github.event_name == 'pull_request' && github.event.action != 'closed') runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - name: Publish Frontend @@ -28,16 +28,12 @@ jobs: Compress-Archive temp/api/** temp/api.zip; Remove-Item -Recurse -Force temp/frontend Remove-Item -Recurse -Force temp/api - - name: Add Artifact App - uses: actions/upload-artifact@v3 + Copy-Item ./build/deploy.ps1 temp/deploy.ps1 + - name: Add Artifact + uses: actions/upload-artifact@v4 with: name: artifact path: temp/ - - name: Add Artifact script - uses: actions/upload-artifact@v3 - with: - name: artifact - path: ./build/deploy.ps1 deploy_job: if: (github.event_name == 'pull_request' && github.event.action != 'closed') runs-on: ubuntu-latest @@ -51,7 +47,7 @@ jobs: pull-requests: write name: Deploy Job steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - name: compile bicep @@ -97,7 +93,7 @@ jobs: runs-on: ubuntu-latest name: Close Pull Request Job steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - name: Get PR title diff --git a/global.json b/global.json index e23437b..04f5d2c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100", + "version": "9.0.303", "rollForward": "latestMajor" } } diff --git a/src/CZ.Azure.FileExchange.Api/AddMetadata.cs b/src/CZ.Azure.FileExchange.Api/AddMetadata.cs index ba89fc8..44b9281 100644 --- a/src/CZ.Azure.FileExchange.Api/AddMetadata.cs +++ b/src/CZ.Azure.FileExchange.Api/AddMetadata.cs @@ -35,7 +35,7 @@ public async Task Run( var events = EventGridEvent.ParseMany(eventsRaw); var relevantChangeTierEvents = events.Where(e => e.EventType == BlobChanged && - e.Data.ToObjectFromJson().api == SetBlobTier + e.Data.ToObjectFromJson()?.api == SetBlobTier ); var relevantValidationEvents = events.Where(e => @@ -47,13 +47,16 @@ public async Task Run( foreach (var tierChangedEvent in relevantChangeTierEvents) { var data = tierChangedEvent.Data.ToObjectFromJson(); + if (data?.url == null) continue; + var blobUri = new Uri(data.url); var containerName = blobUri.Segments.Skip(1).First()[..^1]; var containerClient = blobService.GetBlobContainerClient(containerName); var blobClient = containerClient.GetBlobClient(blobUri.Segments.Last()); - await blobClient.SetMetadataAsync(new Dictionary() { + await blobClient.SetMetadataAsync(new Dictionary + { // That is important to change the 'x-ms-last-access-time' - { "lastTimeRetrieved", tierChangedEvent.EventTime.ToString(CultureInfo.CurrentCulture)} + ["lastTimeRetrieved"] = tierChangedEvent.EventTime.ToString(CultureInfo.CurrentCulture) }); } } @@ -92,20 +95,20 @@ private static string GetEnvironmentVariable(string name) => public class BlobTierChangeEvent { - public string api { get; set; } - public string requestId { get; set; } - public string eTag { get; set; } - public string contentType { get; set; } + public required string api { get; set; } + public required string requestId { get; set; } + public required string eTag { get; set; } + public required string contentType { get; set; } public int contentLength { get; set; } - public string blobType { get; set; } - public string url { get; set; } - public string sequencer { get; set; } - public Storagediagnostics storageDiagnostics { get; set; } + public required string blobType { get; set; } + public required string url { get; set; } + public required string sequencer { get; set; } + public required Storagediagnostics storageDiagnostics { get; set; } } public class Storagediagnostics { - public string batchId { get; set; } + public required string batchId { get; set; } } } diff --git a/src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj b/src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj index abba096..c95baff 100644 --- a/src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj +++ b/src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 v4 Exe enable @@ -8,17 +8,17 @@ 84a717a7-ef76-47be-9101-2a62e74fd7d3 - - - - - - + + + + + + - - - - + + + + diff --git a/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj b/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj index 31c09cb..5deea32 100644 --- a/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj +++ b/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj @@ -1,35 +1,25 @@ - net7.0 + net9.0 enable enable - - - - + + + + - - - - compressed - expanded - - verbose - - High - - - - - - - - + + + + \ No newline at end of file diff --git a/src/CZ.Azure.FileExchange/Client/styles/main.css.map b/src/CZ.Azure.FileExchange/Client/styles/main.css.map new file mode 100644 index 0000000..00a5276 --- /dev/null +++ b/src/CZ.Azure.FileExchange/Client/styles/main.css.map @@ -0,0 +1 @@ +{"version":3,"sourceRoot":"","sources":["vendors/_cssgg.scss","abstracts/_variables.scss","base/_reset.scss","base/_base.scss","base/_typography.scss","layout/_header.scss","layout/_navigation.scss","layout/_main.scss","components/_blazor-error.scss","components/_blazor-splash.scss","components/_button.scss","abstracts/_mixins.scss","components/_input-text.scss","pages/_index.scss","pages/_download.scss"],"names":[],"mappings":"AAAA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;AAAA;EAEC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGA;AAAA;EAEA;EACA;EACA;EACA;;;AAGA;EACA,YACA;EAMA;EACA;EACA;EACA;EACA;;;AAGA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACA;EAGA;EACA;EACA;;;AAGD;AAAA;EAEC;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;ACnMR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;ACjCH;AAAA;AAAA;EAGG;EACA;EACA;EACA;EACA;;;ACJJ;AAAA;EAEI;EACA;;;AAGJ;EACI,aCTG;EDUH;EACA;EACA;EACA,YFdS;;;AIEb;EACI;;AAEA;EACI;EACA,aJSM;EIRN;EACA;EACA;EACA;EACA;;;ACVR;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA,aLMM;EKLN;EACA;EACA;;AAEA;EACI,QLOE;;;AMvBd;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;;;ACRP;EACG;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;;AAKR;EACI;EACA;EACA;;AAEA;EACI;;;ACxBR;AAII;EACI;EACA;EACA,aROM;EQNN;EACA;EACA;EACA,QRUM;;;AQNd;ACdA;EACI;EACA;EACA;EACA;;;AAGJ;EACI;EACA;ECTA;EACA;EACA;EACA;EACA;EACA;EDMA;EACA;EACA;EACA,aTDU;ESEV;EACA;EACA;EAEA;;AAEA;EACI;;AAEJ;EACI;;AAGJ;EACI;EACA;;;AE9BR;EACI;EACA;EACA;;;AAGJ;EDNI;EACA;EACA;EACA;EACA;EACA;ECGA;EACA;EACA;EACA;;AAEA;EACI;EACA,kBXfU;;;AYChB;EFDE;EACA;EACA;EACA;EACA;EACA;EEFA;;AAEA;EACE;EACA,aZMQ;;AYHV;EACE;EACA;EACA;EACA;;AAEA;EACE,kBZZY;;AYed;EACE;;AAMN;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EFrCF;EACA;EACA;EACA;EACA;EACA;EEmCE;;AAEA;EACE;;AAGF;EACE;EACA;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAGF;EACE;;AAGF;EACI;;AAKR;EACE;EACA;EACA;;AAEA;EACE;;AAGE;EACE;;AAGF;EACE;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAIJ;EFrHF;EACA;EACA;EACA;EACA;EACA;EEkHI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIJ;EACE;EACA;EACA;;AAEA;EACE;;;AC3JZ;EACI;EHFA;EACA;EACA;EACA;EACA;EACA;EGAA;;AAGJ;EACI;EACA;EACA;;AAEA;EHbA;EACA;EACA;EACA;EACA;EACA;EGUI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAIJ;EACI;EACA;;AAEA;EACI;EACA,ObhCO;;AakCP;EACI","file":"main.css"} \ No newline at end of file diff --git a/src/CZ.Azure.FileExchange/Pages/Download.razor.cs b/src/CZ.Azure.FileExchange/Pages/Download.razor.cs index 0c051f2..ce182bb 100644 --- a/src/CZ.Azure.FileExchange/Pages/Download.razor.cs +++ b/src/CZ.Azure.FileExchange/Pages/Download.razor.cs @@ -1,11 +1,37 @@ namespace CZ.Azure.FileExchange.Pages; using global::Azure.Storage.Blobs; using global::Azure.Storage.Blobs.Models; +using Microsoft.Extensions.Logging; public partial class Download { + // High-performance logging using LoggerMessage + private static readonly Action LogBlobNotInArchive = + LoggerMessage.Define( + LogLevel.Warning, + new EventId(1, nameof(LogBlobNotInArchive)), + "User tried to retrieve a blob from archive, but the blob was not in the archive tier. The blob: '{BlobName}', tier: '{AccessTier}'"); + + private static readonly Action LogBlobRetrievalStatus = + LoggerMessage.Define( + LogLevel.Warning, + new EventId(2, nameof(LogBlobRetrievalStatus)), + "The blob '{BlobName}' can't be retrieved because the status is {ArchiveStatus}."); + + private static readonly Action LogMultipleBlobsFound = + LoggerMessage.Define( + LogLevel.Warning, + new EventId(3, nameof(LogMultipleBlobsFound)), + "The blob '{BlobName}' exist more then ones. 🫨"); + + private static readonly Action LogBlobNotFound = + LoggerMessage.Define( + LogLevel.Warning, + new EventId(4, nameof(LogBlobNotFound)), + "The blob '{BlobName}' doesn't exist. 🫨"); + private string Code { get; set; } = string.Empty; - private readonly List blobs = new(); + private readonly List blobs = []; private Uri? sasUrl; private async Task LoadFiles() { @@ -51,9 +77,7 @@ private async Task StartRetrivalFromArchive(string blobName) if (blob.Properties.AccessTier != AccessTier.Archive) { - this.logger.LogWarning($"User tried to retrieve a blob from archive, " + - $"but the blob was not in the archive tier." + - $"The blob: '{blob.Name}', tier: '{blob.Properties.AccessTier}'"); + LogBlobNotInArchive(this.logger, blob.Name, blob.Properties.AccessTier, null); /// TODO: make a user visible message that a not archived blob can't be retrieved return; } @@ -65,8 +89,7 @@ private async Task StartRetrivalFromArchive(string blobName) string.Equals(blobProperties.Value.ArchiveStatus, "rehydrate-pending-to-cool", StringComparison.OrdinalIgnoreCase) ) { - this.logger.LogWarning($"The blob '{blob.Name}' can't be retrieved because the " + - $"status is {blobProperties.Value.ArchiveStatus}."); + LogBlobRetrievalStatus(this.logger, blob.Name, blobProperties.Value.ArchiveStatus, null); /// TODO: make a user visible message that the blob can't be double retrieved /// and return } @@ -81,7 +104,7 @@ private async Task StartRetrivalFromArchive(string blobName) if (foundBlobs > 0) { // TODO: something weird happend. We found for our blob we are looking for, more then one real blob. - this.logger.LogWarning($"The blob '{blobName}' exist more then ones. 🫨"); + LogMultipleBlobsFound(this.logger, blobName, null); } this.blobs[blobListEntryLocation] = updatedBlob; } @@ -89,7 +112,7 @@ private async Task StartRetrivalFromArchive(string blobName) else { //TODO: some odd state happend. We change the state of the blob but we can't find it in our blobs list - this.logger.LogWarning($"The blob '{blobName}' doesn't exist. 🫨"); + LogBlobNotFound(this.logger, blobName, null); } diff --git a/src/CZ.Azure.FileExchange/Pages/Index.razor.cs b/src/CZ.Azure.FileExchange/Pages/Index.razor.cs index fb0989b..0934c11 100644 --- a/src/CZ.Azure.FileExchange/Pages/Index.razor.cs +++ b/src/CZ.Azure.FileExchange/Pages/Index.razor.cs @@ -10,9 +10,9 @@ public partial class Index [Inject] private HttpClient Http { get; set; } = default!; - private readonly List files = new(); + private readonly List files = []; private Uri? sasUrl; - private readonly IList fileInputs = new List() { Guid.NewGuid().ToString() }; + private readonly List fileInputs = [Guid.NewGuid().ToString()]; private bool isDragHover; public string? SasId => this.sasUrl?.AbsolutePath?.Replace("/", ""); @@ -78,7 +78,7 @@ private Task DeleteFile(File file) return Task.CompletedTask; } - private class File + private sealed class File { public File(string name, IBrowserFile browserFile, long processedSize = 0) { @@ -93,7 +93,7 @@ public File(string name, IBrowserFile browserFile, long processedSize = 0) public long ProcessedSize { get; set; } } - private class ProgressHandler : IProgress + private sealed class ProgressHandler : IProgress { private readonly Index pageRef; private readonly File file;