Skip to content

Commit 0db81f9

Browse files
authored
Update frontend to dotnet7 part2 (#29)
* update packages and framework * update global json * update pipelines * only update dependcies. * try to fix the pipelines for our special build setup * try to migrate the functions too to dotnet 7 * try to allow dotnet 7 * add deploy.ps1 to the solution * try to use dotnet 7 in the deployment * try to fix the deployment * try to fix deployment * fix the deployment * additional logging, if the deployment failed * fix functions startup * try to fix the deploy script a bit more * try to fix deployment again * change settings files * update packages * try with a diffrent framework identifier * try it with the old version again * try to build self contained * try to fix pipeline * fix pipeline again * fix a minor issue in the custom deploy script * try to use the latest and greatest worker updates * try now with x86. Maybe it will fix it
1 parent f48e9df commit 0db81f9

File tree

12 files changed

+77
-34
lines changed

12 files changed

+77
-34
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ jobs:
3131
uses: actions/[email protected]
3232
with:
3333
# Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x
34-
dotnet-version: 6.0.x
34+
dotnet-version: |
35+
7.0.x
36+
6.0.x
3537
- name: Restore dependencies
3638
run: dotnet restore
3739
- name: Build
3840
run: dotnet build -c Release --no-restore
3941
- name: Publish Frontend
4042
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange/ -o temp/frontend
4143
- name: Publish API
42-
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange.Api/ -o temp/api
44+
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange.Api/ -o temp/api --runtime win-x86 --no-self-contained
4345
- name: Deploy
4446
id: deploy
45-
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 }} -Verbose'
47+
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'
4648
shell: pwsh
4749
- name: comment-pr
4850
uses: JoseThen/[email protected]
@@ -68,7 +70,7 @@ jobs:
6870
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6971
continue-on-error: true
7072
- name: Deploy
71-
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 }} -Verbose -Delete'
73+
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'
7274
shell: pwsh
7375
compile_bicep:
7476
runs-on: 'ubuntu-latest'
@@ -80,4 +82,4 @@ jobs:
8082
- name: compile bicep
8183
uses: Azure/[email protected]
8284
with:
83-
bicepFilePath: main.bicep
85+
bicepFilePath: main.bicep

CZ.Azure.FileExchange.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
ProjectSection(SolutionItems) = preProject
1515
.gitignore = .gitignore
1616
azure-pipelines.yml = azure-pipelines.yml
17+
build\deploy.ps1 = build\deploy.ps1
18+
global.json = global.json
1719
main.bicep = main.bicep
20+
.github\workflows\main.yml = .github\workflows\main.yml
1821
Readme.md = Readme.md
1922
EndProjectSection
2023
EndProject

azure-pipelines.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ stages:
2525
vmImage: $(vmImageName)
2626

2727
steps:
28+
- task: UseDotNet@2
29+
inputs:
30+
packageType: 'sdk'
31+
version: '7.x'
2832
- task: UseDotNet@2
2933
inputs:
3034
packageType: 'sdk'
@@ -50,7 +54,7 @@ stages:
5054
inputs:
5155
command: 'publish'
5256
projects: $(workingDirectory)/src/CZ.Azure.FileExchange.Api/CZ.Azure.FileExchange.Api.csproj
53-
arguments: --output $(workingDirectory)/api --configuration Release
57+
arguments: --output $(workingDirectory)/api --configuration Release --runtime win-x86 --no-self-contained
5458
zipAfterPublish: false
5559
workingDirectory: $(workingDirectory)/src/CZ.Azure.FileExchange.Api/
5660
publishWebProjects: false

build/deploy.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ param (
1212
[Parameter(Mandatory = $true)]
1313
[string]
1414
$apiBuildOutput,
15+
# the framework your API is written in
16+
[Parameter(Mandatory = $false)]
17+
[string]
18+
$apiFramework = "dotnet",
19+
# the version of your framework
20+
[Parameter(Mandatory = $false)]
21+
[string]
22+
$apiFrameworkVersion = "6.0.0",
1523
# Set a custom working directory.
1624
[Parameter(Mandatory = $false)]
1725
[string]
@@ -133,11 +141,13 @@ $metaDeployInforamtion = @{
133141
ConfiguredRoles = @();
134142
DefaultFileType = "index.html";
135143
# this can be anything
136-
DeploymentProvider = "myown";
137-
FunctionLanguage = "dotnet";
138-
FunctionLanguageVersion = "6.0.0";
144+
DeploymentProvider = "Custom";
145+
FunctionLanguage = $apiFramework;
146+
FunctionLanguageVersion = $apiFrameworkVersion;
147+
HasDataApiFiles = $false
139148
HasFunctions = $true;
140149
HasRoutes = $false;
150+
ServerRenderFramework = "StaticWebApp"
141151
Status = "RequestingUpload";
142152
}
143153
}
@@ -209,5 +219,8 @@ while (
209219
if((Test-Path $workingDir)){
210220
Remove-Item -Recurse -Force $workingDir;
211221
}
222+
if($response.response.deploymentStatus -ne 'Succeeded'){
223+
throw "The deployment failed. The reason was: $($response.response.errorDetails)";
224+
}
212225
$response.response.siteUrl;
213-
Write-Output "::set-output name=SiteUrl::$($response.response.siteUrl)";
226+
Write-Output "::set-output name=SiteUrl::$($response.response.siteUrl)";

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.200",
3+
"version": "7.0.100",
44
"rollForward": "latestMajor"
55
}
66
}
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net7.0</TargetFramework>
44
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
5+
<OutputType>Exe</OutputType>
6+
<ImplicitUsings>enable</ImplicitUsings>
57
<Nullable>enable</Nullable>
68
</PropertyGroup>
79
<ItemGroup>
810
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
9-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="1.4.0" />
10-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
11+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
12+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
13+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.1" />
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
1115
</ItemGroup>
1216
<ItemGroup>
1317
<None Update="host.json">
1418
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1519
</None>
1620
<None Update="local.settings.json">
17-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1822
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
1923
</None>
2024
</ItemGroup>
21-
</Project>
25+
<ItemGroup>
26+
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
27+
</ItemGroup>
28+
</Project>

src/CZ.Azure.FileExchange.Api/GenerateSas.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ namespace CZ.Azure.FileExchange.Api;
33
using System;
44
using System.Net;
55
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Http;
76
using Microsoft.AspNetCore.Mvc;
8-
using Microsoft.Azure.WebJobs;
9-
using Microsoft.Azure.WebJobs.Extensions.Http;
10-
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
7+
using Microsoft.Azure.Functions.Worker;
118
using Microsoft.Extensions.Logging;
129
using Microsoft.OpenApi.Models;
1310
using global::Azure.Storage.Blobs;
1411
using global::Azure.Storage.Sas;
15-
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions;
1612
using System.Net.Http;
13+
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
14+
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions;
15+
using Microsoft.Azure.Functions.Worker.Http;
1716

1817
public class GenerateSas
1918
{
@@ -22,19 +21,20 @@ public class GenerateSas
2221
public GenerateSas(ILogger<GenerateSas> log) =>
2322
this.logger = log;
2423

25-
[FunctionName("GenerateSas")]
24+
[Function("GenerateSas")]
2625
[OpenApiOperation(operationId: "Run")]
2726
[OpenApiParameter(name: "filecode", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "The **code** parameter, that represent to get read access to stored files")]
2827
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]
2928
public async Task<IActionResult> Run(
30-
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
29+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequestData req)
3130
{
3231
this.logger.LogInformation("Start generating SaS");
3332

3433
var blobservice = new BlobServiceClient(GetEnvironmentVariable("StorageConnectionString"));
3534
Uri? uri;
3635
BlobContainerClient? blobContainerClient;
37-
if (req.Query.TryGetValue("filecode", out var code))
36+
var code = req.Url.ParseQueryString().Get("filecode");
37+
if (code != null)
3838
{
3939
blobContainerClient = blobservice.GetBlobContainerClient(code);
4040
uri = this.GetServiceSasUriForContainer(blobContainerClient, BlobSasPermissions.Read | BlobSasPermissions.List);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Extensions;
2+
using Microsoft.Extensions.Hosting;
3+
4+
var host = new HostBuilder()
5+
.ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
6+
.ConfigureOpenApi()
7+
.Build();
8+
9+
host.Run();
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"version": "2.0",
2+
"version": "2.0",
33
"logging": {
44
"applicationInsights": {
55
"samplingSettings": {
66
"isEnabled": true,
7-
"excludedTypes": "Request"
7+
"excludedTypes": "Request"
88
}
99
}
10-
}
10+
}
1111
}

src/CZ.Azure.FileExchange.Api/local.settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"IsEncrypted": false,
33
"Values": {
4-
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
4+
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
55
"StorageConnectionString": "DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"
66
},
77
"Host": {

0 commit comments

Comments
 (0)