Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "9.0.303",
"rollForward": "latestMajor"
}
}
27 changes: 15 additions & 12 deletions src/CZ.Azure.FileExchange.Api/AddMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<HttpResponseData> Run(
var events = EventGridEvent.ParseMany(eventsRaw);
var relevantChangeTierEvents = events.Where(e =>
e.EventType == BlobChanged &&
e.Data.ToObjectFromJson<BlobTierChangeEvent>().api == SetBlobTier
e.Data.ToObjectFromJson<BlobTierChangeEvent>()?.api == SetBlobTier
);

var relevantValidationEvents = events.Where(e =>
Expand All @@ -47,13 +47,16 @@ public async Task<HttpResponseData> Run(
foreach (var tierChangedEvent in relevantChangeTierEvents)
{
var data = tierChangedEvent.Data.ToObjectFromJson<BlobTierChangeEvent>();
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<string, string>() {
await blobClient.SetMetadataAsync(new Dictionary<string, string>
{
// That is important to change the 'x-ms-last-access-time'
{ "lastTimeRetrieved", tierChangedEvent.EventTime.ToString(CultureInfo.CurrentCulture)}
["lastTimeRetrieved"] = tierChangedEvent.EventTime.ToString(CultureInfo.CurrentCulture)
});
}
}
Expand Down Expand Up @@ -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; }
}

}
22 changes: 11 additions & 11 deletions src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>84a717a7-ef76-47be-9101-2a62e74fd7d3</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.14.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.1" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.13.1" />
<PackageReference Include="Azure.Storage.Queues" Version="12.13.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.13.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.28.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.21.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.7.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.18.1" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down
34 changes: 12 additions & 22 deletions src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DartSassBuilder" Version="0.3.0-beta" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
<!-- <PackageReference Include="DartSassBuilder" Version="1.1.0" /> -->
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
</ItemGroup>

<!-- SASS options -->
<PropertyGroup>
<!-- outputstyle option -->
<DartSassOutputStyle>compressed</DartSassOutputStyle>
<DartSassOutputStyle Condition="'$(Configuration)' == 'Debug'">expanded</DartSassOutputStyle>
<!-- level option -->
<DartSassOutputLevel>verbose</DartSassOutputLevel>
<!-- msbuild output level -->
<DartSassMessageLevel>High</DartSassMessageLevel>
</PropertyGroup>
<ItemGroup>
<!-- add files manually -->
<SassFile Include="Client/**/*.scss" />
</ItemGroup>

<Target Name="copy_sass_to_the_right_place" AfterTargets="DartSass_Build">
<Copy SourceFiles="Client/styles/main.css" DestinationFolder="wwwroot/client/" />
<!-- Custom SASS compilation using native sass command -->
<Target Name="CompileSass" BeforeTargets="Build">
<Exec Command="sass Client/styles/main.scss Client/styles/main.css --style=expanded"
ContinueOnError="false"
WorkingDirectory="$(MSBuildProjectDirectory)" />
<Copy SourceFiles="$(MSBuildProjectDirectory)/Client/styles/main.css"
DestinationFolder="$(MSBuildProjectDirectory)/wwwroot/client/" />
</Target>

</Project>
1 change: 1 addition & 0 deletions src/CZ.Azure.FileExchange/Client/styles/main.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 31 additions & 8 deletions src/CZ.Azure.FileExchange/Pages/Download.razor.cs
Original file line number Diff line number Diff line change
@@ -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<ILogger, string, AccessTier?, Exception?> LogBlobNotInArchive =
LoggerMessage.Define<string, AccessTier?>(
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<ILogger, string, string?, Exception?> LogBlobRetrievalStatus =
LoggerMessage.Define<string, string?>(
LogLevel.Warning,
new EventId(2, nameof(LogBlobRetrievalStatus)),
"The blob '{BlobName}' can't be retrieved because the status is {ArchiveStatus}.");

private static readonly Action<ILogger, string, Exception?> LogMultipleBlobsFound =
LoggerMessage.Define<string>(
LogLevel.Warning,
new EventId(3, nameof(LogMultipleBlobsFound)),
"The blob '{BlobName}' exist more then ones. 🫨");

private static readonly Action<ILogger, string, Exception?> LogBlobNotFound =
LoggerMessage.Define<string>(
LogLevel.Warning,
new EventId(4, nameof(LogBlobNotFound)),
"The blob '{BlobName}' doesn't exist. 🫨");

private string Code { get; set; } = string.Empty;
private readonly List<BlobItem> blobs = new();
private readonly List<BlobItem> blobs = [];
private Uri? sasUrl;
private async Task LoadFiles()
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
}
Expand All @@ -81,15 +104,15 @@ 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;
}
}
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);
}


Expand Down
8 changes: 4 additions & 4 deletions src/CZ.Azure.FileExchange/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public partial class Index
[Inject]
private HttpClient Http { get; set; } = default!;

private readonly List<File> files = new();
private readonly List<File> files = [];
private Uri? sasUrl;
private readonly IList<string> fileInputs = new List<string>() { Guid.NewGuid().ToString() };
private readonly List<string> fileInputs = [Guid.NewGuid().ToString()];
private bool isDragHover;

public string? SasId => this.sasUrl?.AbsolutePath?.Replace("/", "");
Expand Down Expand Up @@ -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)
{
Expand All @@ -93,7 +93,7 @@ public File(string name, IBrowserFile browserFile, long processedSize = 0)
public long ProcessedSize { get; set; }
}

private class ProgressHandler : IProgress<long>
private sealed class ProgressHandler : IProgress<long>
{
private readonly Index pageRef;
private readonly File file;
Expand Down
Loading