Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to dotnet 8.0 #39

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal
ARG VARIANT="6.0-bullseye-slim"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
FROM mcr.microsoft.com/devcontainers/dotnet:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
9 changes: 6 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "7.0",
"VARIANT": "8.0-jammy",
// Options
"NODE_VERSION": "lts/*"
}
@@ -17,7 +17,7 @@
"version": "latest"
},
"ghcr.io/devcontainers/features/dotnet": {
"version": "7.0",
"version": "8.0",
"additionalVersions": "6.0",
"runtimeOnly": false
},
@@ -47,7 +47,10 @@
"cschleiden.vscode-github-actions",
"ms-azure-devops.azure-pipelines",
"github.vscode-github-actions",
"ms-vscode.powershell"
"ms-vscode.powershell",
"ms-dotnettools.csdevkit",
"ms-dotnettools.vscodeintellicode-csharp",
"chneau.resource-monitor"
]
}
},
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -17,10 +17,13 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Publish Frontend
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange/ -o temp/frontend
- name: Publish API
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange.Api/ -o temp/api --runtime win-x86 --no-self-contained
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange.Api/ -o temp/api --runtime win-x86 --self-contained
- name: zip outputs
shell: pwsh
run: |
@@ -110,5 +113,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Deploy
run: './build/deploy.ps1 -Token ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KINDDUNE004C2C103 }} -appBuildOutput ./temp/frontend/wwwroot/ -apiBuildOutput ./temp/api/ -envrionmentName ${{ github.event.number }} -pullrequestTitle "${{steps.Pr-Title.outputs.pr-title}}" -branchName ${{ github.head_ref }} -apiFramework "dotnetisolated" -apiFrameworkVersion "7.0" -Verbose -Delete'
shell: pwsh
run: './build/deploy.ps1 -Token ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KINDDUNE004C2C103 }} -appBuildOutput ./temp/frontend/wwwroot/ -apiBuildOutput ./temp/api/ -envrionmentName ${{ github.event.number }} -pullrequestTitle "${{steps.Pr-Title.outputs.pr-title}}" -branchName ${{ github.head_ref }} -apiFramework "dotnetisolated" -apiFrameworkVersion "8.0" -Verbose -Delete'
shell: pwsh
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"azureFunctions.projectSubpath": "src/CZ.Azure.FileExchange.Api",
"azureFunctions.deploySubpath": "src/CZ.Azure.FileExchange.Api/bin/Release/net7.0/publish",
"azureFunctions.deploySubpath": "src/CZ.Azure.FileExchange.Api/bin/Release/net8.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api/bin/Debug/net7.0"
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api/bin/Debug/net8.0"
},
"command": "host start",
"isBackground": true,
12 changes: 7 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -41,9 +41,9 @@ $token = Read-Host -MaskInput;
> Important: If you want deploy this, build it on linux!

```powershell
dotnet build
dotnet publish .\src\CZ.Azure.FileExchange\ -o temp/fe
dotnet publish .\src\CZ.Azure.FileExchange.Api\ -o temp/api
dotnet build -c Release
dotnet publish -c Release .\src\CZ.Azure.FileExchange\ -o temp/fe
dotnet publish --runtime win-x86 --no-self-contained -c Release .\src\CZ.Azure.FileExchange.Api\ -o temp/api
```

### Run the App local
@@ -71,13 +71,14 @@ $body = "<?xml version=`"1.0`" encoding=`"utf-8`"?>
</Cors>
</StorageServiceProperties>"
$lenght = $body.Length;
$bodyMd5 = ([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($body)))).Replace("-","");
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256;
$hmacsha.key = [Convert]::FromBase64String($accountKey);
$date = (Get-Date).ToUniversalTime().ToString("R");
$test = "PUT`n`n`n$lenght`n`n`n`n`n`n`n`n`nx-ms-date:$($date)`nx-ms-version:2018-03-28`n/devstoreaccount1/devstoreaccount1`ncomp:properties`nrestype:service";
$test = "PUT`n`n`n$lenght`n`napplication/x-www-form-urlencoded`n`n`n`n`n`n`nx-ms-date:$($date)`nx-ms-version:2024-02-04`n/devstoreaccount1/devstoreaccount1`ncomp:properties`nrestype:service";
$signature1 = $hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($test));
$auth = [System.Convert]::ToBase64String($signature1);
Invoke-WebRequest -Method Put "http://127.0.0.1:10000/devstoreaccount1?restype=service&comp=properties" -Headers @{"Authorization" = "SharedKey devstoreaccount1:$($auth)"; "x-ms-version"= "2018-03-28"; "x-ms-date" = $date } -Body $body
Invoke-WebRequest -Method Put "http://127.0.0.1:10000/devstoreaccount1?restype=service&comp=properties" -Headers @{"Authorization" = "SharedKey devstoreaccount1:$($auth)"; "x-ms-version"= "2024-02-04"; "x-ms-date" = $date } -Body $body
```


@@ -115,3 +116,4 @@ $PrId = "Replace this string with the Id of your PR here";
$PrTitle = "Replace this string with the title of your PR";
./build/deploy.ps1 -Token $token -appBuildOutput ./temp/fe/wwwroot/ -apiBuildOutput ./temp/api/ -envrionmentName $PrId -pullrequestTitle $PrTitle -branchName $branchName -Delete
```

2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ stages:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '7.x'
version: '8.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
8 changes: 6 additions & 2 deletions deploayWebApp.bicep
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ resource deployPrWebApp 'Microsoft.Resources/deploymentScripts@2020-10-01' = if
[string] $branch,
[string] $prNumber
)
# this makes it easier for us to read the log output
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
try{
# download artifact from pipeline run
$workflowArtifactUrl = "$($githubRuntimeApiUrl)_apis/pipelines/workflows/$githubRunId/artifacts";
@@ -77,7 +79,7 @@ resource deployPrWebApp 'Microsoft.Resources/deploymentScripts@2020-10-01' = if
Set-Location ./artifact/
$secretProperties = Get-AzStaticWebAppSecret -Name $staticWebAppName -ResourceGroupName $resourceGroupName
$token = $secretProperties.Property.Item("apiKey")
./deploy.ps1 -Token $token -appBuildOutput ./frontend.zip -apiBuildOutput ./api.zip -apiFramework "dotnetisolated" -apiFrameworkVersion "7.0" -workingDir $pwd -branchName $branch -envrionmentName $prNumber -Verbose
./deploy.ps1 -Token $token -appBuildOutput ./frontend.zip -apiBuildOutput ./api.zip -apiFramework "dotnetisolated" -apiFrameworkVersion "8.0" -workingDir $pwd -branchName $branch -envrionmentName $prNumber -Verbose
# for azure Deployment Script output
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['staticWebUrl'] = "https://$((Get-AzStaticWebAppBuild -Name $staticWebAppName -ResourceGroupName $resourceGroupName -EnvironmentName $prNumber).Hostname)"
@@ -112,6 +114,8 @@ resource deployWebApp 'Microsoft.Resources/deploymentScripts@2020-10-01' = if (e
[string] $staticWebAppName,
[string] $resourceGroupName
)
# this makes it easier for us to read the log output
$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;
# take stable releases here
$result = Invoke-RestMethod https://api.github.com/repos/codez-one/CZ.Azure.FileExchange/releases/latest -Headers @{"X-GitHub-Api-Version" = "2022-11-28" }
$frontendDownloadUrl = ($result.assets | ? {$_.name -like 'Frontend.zip'}).browser_download_url;
@@ -127,7 +131,7 @@ resource deployWebApp 'Microsoft.Resources/deploymentScripts@2020-10-01' = if (e
$secretProperties = Get-AzStaticWebAppSecret -Name $staticWebAppName -ResourceGroupName $resourceGroupName
$token = $secretProperties.Property.Item("apiKey")
$token.Substring(0,5)
./deploy.ps1 -Token $token -appBuildOutput ./frontend.zip -apiBuildOutput ./api.zip -apiFramework "dotnetisolated" -apiFrameworkVersion "7.0" -workingDir $pwd -Verbose
./deploy.ps1 -Token $token -appBuildOutput ./frontend.zip -apiBuildOutput ./api.zip -apiFramework "dotnetisolated" -apiFrameworkVersion "8.0" -workingDir $pwd -Verbose
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['staticWebUrl'] = "https://$((Get-AzStaticWebApp -Name $staticWebAppName -ResourceGroupName $resourceGroupName).DefaultHostname)"
'''
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": "8.0.101",
"rollForward": "latestMajor"
}
}
9 changes: 3 additions & 6 deletions src/CZ.Azure.FileExchange.Api/AddMetadata.cs
Original file line number Diff line number Diff line change
@@ -3,25 +3,22 @@
using System;
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using global::Azure.Messaging.EventGrid;
using Microsoft.Azure.Functions.Worker.Http;
using global::Azure.Messaging.EventGrid.SystemEvents;
using global::Azure.Storage.Blobs;
using System.Globalization;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;

public class AddMetadata
public class AddMetadata(ILoggerFactory loggerFactory)
{
private readonly ILogger logger;
private readonly ILogger logger = loggerFactory.CreateLogger<AddMetadata>();
private const string BlobChanged = "Microsoft.Storage.BlobTierChanged";
private const string SetBlobTier = "SetBlobTier";
private const string AzureValidation = "Microsoft.EventGrid.SubscriptionValidationEvent";


public AddMetadata(ILoggerFactory loggerFactory) => this.logger = loggerFactory.CreateLogger<AddMetadata>();

[Function("AddMetadata")]
[OpenApiOperation(operationId: "Run")]
[OpenApiRequestBody("application/json", typeof(IEnumerable<EventGridEvent>))]
@@ -92,20 +89,20 @@

public class BlobTierChangeEvent
{
public string api { get; set; }

Check warning on line 92 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'api' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string requestId { get; set; }

Check warning on line 93 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'requestId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string eTag { get; set; }

Check warning on line 94 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'eTag' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string contentType { get; set; }

Check warning on line 95 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'contentType' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int contentLength { get; set; }
public string blobType { get; set; }

Check warning on line 97 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'blobType' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string url { get; set; }

Check warning on line 98 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'url' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string sequencer { get; set; }

Check warning on line 99 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'sequencer' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public Storagediagnostics storageDiagnostics { get; set; }

Check warning on line 100 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'storageDiagnostics' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}

public class Storagediagnostics
{
public string batchId { get; set; }

Check warning on line 105 in src/CZ.Azure.FileExchange.Api/AddMetadata.cs

GitHub Actions / build_only

Non-nullable property 'batchId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}

}
26 changes: 15 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,28 @@
<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" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.21.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.17.1" />
<PackageReference Include="Azure.Storage.Queues" Version="12.17.1" />
<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.2.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
6 changes: 3 additions & 3 deletions src/CZ.Azure.FileExchange.Api/GenerateSas.cs
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ namespace CZ.Azure.FileExchange.Api;
using global::Azure.Storage.Blobs;
using global::Azure.Storage.Sas;
using System.Net.Http;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions;
using Microsoft.Azure.Functions.Worker.Http;

public class GenerateSas
{
@@ -52,13 +52,13 @@ public async Task<HttpResponseData> Run(
var badResponse = req.CreateResponse(HttpStatusCode.BadRequest);
var badContent = new StringContent("Failed to greate SaS token to upload your files. Please try again.");
badResponse.Headers.Add("Content-Type", badContent.Headers.ContentType?.ToString());
badResponse.WriteString(await badContent.ReadAsStringAsync());
await badResponse.WriteStringAsync(await badContent.ReadAsStringAsync());
return badResponse;
}
var okResponse = req.CreateResponse(HttpStatusCode.OK);
var content = new StringContent(uri.ToString());
okResponse.Headers.Add("Content-Type", content.Headers.ContentType?.ToString());
okResponse.WriteString(await content.ReadAsStringAsync());
await okResponse.WriteStringAsync(await content.ReadAsStringAsync());
return okResponse;
}

2 changes: 1 addition & 1 deletion src/CZ.Azure.FileExchange.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
{
services.AddHttpClient();
})
.ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
.ConfigureFunctionsWebApplication(worker => worker.UseNewtonsoftJson())
.ConfigureOpenApi()
.Build();

15 changes: 5 additions & 10 deletions src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.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.0.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.1" />
</ItemGroup>

<!-- SASS options -->
<PropertyGroup>
<!-- outputstyle option -->
@@ -27,9 +24,7 @@
<!-- 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/" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/CZ.Azure.FileExchange/staticwebapp.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"platform": {
"apiRuntime": "dotnet-isolated:7.0"
"apiRuntime": "dotnet-isolated:8.0"
}
}
3 changes: 3 additions & 0 deletions src/CZ.Azure.FileExchange/wwwroot/staticwebapp.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"platform": {
"apiRuntime": "dotnet-isolated:8.0"
},
"navigationFallback": {
"rewrite": "/index.html",
"exclude": [
Loading