Skip to content

Commit 092e1db

Browse files
Upgrade to .NET 8 (Azure-Samples#191)
I just now saw Azure-Samples#186, I didn't realize before that there was an effort in place to do this work. There are parts of that PR that look good—@luisquintanilla how should we proceed? I pulled in the changes from the PR that I liked. ~Let's add the CPM in a separate PR, since versions weren't bumped~. I've bumped the versions, and I'm updating this PR to utilize the CPM feature since it does improve the `PacakgeReference` experience. --------- Co-authored-by: XiaoYun Zhang <[email protected]>
1 parent bd0a6c9 commit 092e1db

38 files changed

+368
-335
lines changed

.devcontainer/devcontainer.json

+42-39
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
{
2-
"name": "Azure Developer CLI",
3-
"image": "mcr.microsoft.com/devcontainers/dotnet:0-7.0-bullseye",
4-
"features": {
5-
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6-
"ghcr.io/devcontainers/features/azure-cli:1.2.1": {},
7-
"ghcr.io/devcontainers/features/github-cli:1.0.9": {},
8-
"ghcr.io/azure/azure-dev/azd:latest": {}
2+
"name": "Azure Search OpenAI Demo - C#",
3+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6+
"ghcr.io/devcontainers/features/azure-cli:1.2.1": {},
7+
"ghcr.io/devcontainers/features/github-cli:1.0.9": {},
8+
"ghcr.io/devcontainers/features/powershell:1.1.0": {},
9+
"ghcr.io/azure/azure-dev/azd:latest": {},
10+
"ghcr.io/devcontainers/features/dotnet:2": {
11+
"version": "8.0"
912
},
10-
"customizations": {
11-
"vscode": {
12-
"extensions": [
13-
"ms-azuretools.azure-dev",
14-
"ms-azuretools.vscode-bicep",
15-
"ms-azuretools.vscode-docker",
16-
"ms-vscode.vscode-node-azure-pack",
17-
"ms-dotnettools.csharp",
18-
"ms-dotnettools.vscode-dotnet-runtime",
19-
"ms-azuretools.vscode-azurefunctions",
20-
"ms-azuretools.vscode-cosmosdb",
21-
"ms-azuretools.vscode-azurestorage",
22-
"ms-vscode.azurecli",
23-
"ms-kubernetes-tools.vscode-aks-tools",
24-
"ms-kubernetes-tools.aks-devx-tools",
25-
"ms-azuretools.vscode-azurecontainerapps",
26-
"ms-azuretools.vscode-azureeventgrid",
27-
"ms-kubernetes-tools.vscode-kubernetes-tools",
28-
"ipedrazas.kubernetes-snippets",
29-
"redhat.vscode-yaml",
30-
"GitHub.vscode-github-actions"
31-
]
32-
}
33-
},
34-
"forwardPorts": [
35-
5000
36-
],
37-
"postCreateCommand": "",
38-
"remoteUser": "vscode",
39-
"hostRequirements": {
40-
"memory": "8gb"
13+
"ghcr.io/devcontainers/features/node:1": {
14+
"version": "20.6.1"
15+
}
16+
},
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"ms-azuretools.vscode-docker",
21+
"ms-azuretools.vscode-azurefunctions",
22+
"ms-azuretools.vscode-azurestorage",
23+
"ms-azuretools.vscode-azurecontainerapps",
24+
"ms-dotnettools.csdevkit",
25+
"ms-dotnettools.vscode-dotnet-runtime",
26+
"ms-dotnettools.blazorwasm-companion",
27+
"ms-kubernetes-tools.vscode-aks-tools",
28+
"ms-kubernetes-tools.aks-devx-tools",
29+
"ms-kubernetes-tools.vscode-kubernetes-tools",
30+
"ipedrazas.kubernetes-snippets",
31+
"redhat.vscode-yaml",
32+
"GitHub.vscode-github-actions",
33+
"esbenp.prettier-vscode"
34+
]
4135
}
42-
}
36+
},
37+
"forwardPorts": [
38+
5000
39+
],
40+
"postCreateCommand": "",
41+
"remoteUser": "vscode",
42+
"hostRequirements": {
43+
"memory": "8gb"
44+
}
45+
}

.github/workflows/azure-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Setup .NET
5555
uses: actions/setup-dotnet@v3
5656
with:
57-
dotnet-version: 7.0.x
57+
dotnet-version: 8.0.x
5858

5959
- name: Log in with Azure (Federated Credentials)
6060
if: ${{ env.AZURE_CLIENT_ID != '' }}

.github/workflows/dotnet-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v3
1818
with:
19-
dotnet-version: 7.0.x
19+
dotnet-version: 8.0.x
2020
- name: Restore dependencies
2121
run: dotnet restore ./app/app.sln
2222
- name: Build

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dotnet/.config
4040
*.user
4141
*.userosscache
4242
*.sln.docstates
43-
nuget.config
4443

4544
# User-specific files (MonoDevelop/Xamarin Studio)
4645
*.userprefs

.vscode/extensions.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
{
22
"recommendations": [
3-
"ms-azuretools.azure-dev",
4-
"ms-azuretools.vscode-bicep",
5-
"ms-dotnettools.blazorwasm-companion",
6-
"ms-dotnettools.csharp",
7-
"ms-dotnettools.vscode-dotnet-runtime",
3+
"ms-azuretools.vscode-azurefunctions",
4+
"ms-dotnettools.csharp",
5+
"ms-azuretools.vscode-docker",
6+
"ms-azuretools.vscode-azurestorage",
7+
"ms-azuretools.vscode-azurecontainerapps",
8+
"ms-dotnettools.csdevkit",
9+
"ms-dotnettools.vscode-dotnet-runtime",
10+
"ms-dotnettools.blazorwasm-companion",
11+
"ms-kubernetes-tools.vscode-aks-tools",
12+
"ms-kubernetes-tools.aks-devx-tools",
13+
"ms-kubernetes-tools.vscode-kubernetes-tools",
14+
"ipedrazas.kubernetes-snippets",
15+
"redhat.vscode-yaml",
16+
"GitHub.vscode-github-actions",
17+
"esbenp.prettier-vscode"
818
]
9-
}
19+
}

.vscode/launch.json

+40-42
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,48 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"type": "PowerShell",
9-
"request": "launch",
10-
"name": "PowerShell Launch (current file)",
11-
"script": "${file}",
12-
"args": [],
13-
"cwd": "${file}"
7+
{
8+
"name": "Frontend: Blazor client",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
"program": "${workspaceFolder}//app/backend/bin/Debug/net8.0/ClientApp.dll",
13+
"args": [],
14+
"cwd": "${workspaceFolder}",
15+
"stopAtEntry": false,
16+
"serverReadyAction": {
17+
"action": "openExternally",
18+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
1419
},
15-
{
16-
"name": "Frontend: Blazor client",
17-
"type": "coreclr",
18-
"request": "launch",
19-
"preLaunchTask": "build",
20-
"program": "${workspaceFolder}/app/frontend/bin/Debug/net7.0/ClientApp.dll",
21-
"args": [],
22-
"cwd": "${workspaceFolder}",
23-
"stopAtEntry": false,
24-
"serverReadyAction": {
25-
"action": "openExternally",
26-
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
27-
},
28-
"env": {
29-
"ASPNETCORE_ENVIRONMENT": "Development"
30-
},
31-
"envFile": "${input:dotEnvFilePath}"
20+
"env": {
21+
"ASPNETCORE_ENVIRONMENT": "Development"
3222
},
33-
{
34-
"name": "Backend: Minimal API",
35-
"type": "coreclr",
36-
"request": "launch",
37-
"preLaunchTask": "build",
38-
"program": "${workspaceFolder}/app/backend/bin/Debug/net7.0/MinimalApi.dll",
39-
"args": [],
40-
"cwd": "${workspaceFolder}",
41-
"stopAtEntry": false,
42-
"console": "internalConsole",
43-
"envFile": "${input:dotEnvFilePath}"
44-
}
23+
"envFile": "${input:dotEnvFilePath}"
24+
},
25+
{
26+
"name": "Backend: Minimal API",
27+
"type": "coreclr",
28+
"request": "launch",
29+
"preLaunchTask": "build",
30+
"program": "${workspaceFolder}/app/backend/bin/Debug/net8.0/MinimalApi.dll",
31+
"args": [],
32+
"cwd": "${workspaceFolder}",
33+
"stopAtEntry": false,
34+
"console": "internalConsole",
35+
"envFile": "${input:dotEnvFilePath}"
36+
}
4537
],
4638
"inputs": [
47-
{
48-
"id": "dotEnvFilePath",
49-
"type": "command",
50-
"command": "azure-dev.commands.getDotEnvFilePath"
51-
}
39+
{
40+
"id": "dotEnvFilePath",
41+
"type": "command",
42+
"command": "azure-dev.commands.getDotEnvFilePath"
43+
}
44+
],
45+
"compounds": [
46+
{
47+
"name": "Full Stack",
48+
"configurations": ["Backend: Minimal API", "Frontend: Blazor client"]
49+
}
5250
]
53-
}
51+
}

.vscode/settings.json

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
{
22
"[javascript]": {
3-
"editor.defaultFormatter": "esbenp.prettier-vscode",
4-
"editor.formatOnSave": true
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.formatOnSave": true
55
},
66
"[typescript]": {
7-
"editor.defaultFormatter": "esbenp.prettier-vscode",
8-
"editor.formatOnSave": true
7+
"editor.defaultFormatter": "esbenp.prettier-vscode",
8+
"editor.formatOnSave": true
99
},
1010
"[css]": {
11-
"editor.defaultFormatter": "esbenp.prettier-vscode",
12-
"editor.formatOnSave": true
11+
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
"editor.formatOnSave": true
1313
},
1414
"search.exclude": {
15-
"static": true
15+
"static": true
1616
},
17-
"dotnet.defaultSolution": "app/app.sln"
18-
}
17+
"dotnet.defaultSolution": "app/app.sln",
18+
"azureFunctions.deploySubpath": "app/functions/EmbedFunctions/bin/Release/net8.0/publish",
19+
"azureFunctions.projectLanguage": "C#",
20+
"azureFunctions.projectRuntime": "~4",
21+
"debug.internalConsoleOptions": "neverOpen",
22+
"azureFunctions.projectSubpath": "app/functions/EmbedFunctions",
23+
"azureFunctions.preDeployTask": "publish (functions)"
24+
}

app/Directory.Packages.props

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="Azure.AI.FormRecognizer" Version="4.1.0" />
7+
<PackageVersion Include="Azure.AI.OpenAI" Version="1.0.0-beta.8" />
8+
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
9+
<PackageVersion Include="Azure.Identity" Version="1.10.2" />
10+
<PackageVersion Include="Azure.Search.Documents" Version="11.5.0-beta.5" />
11+
<PackageVersion Include="Azure.Storage.Blobs" Version="12.18.0" />
12+
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.16.0" />
13+
<PackageVersion Include="Azure.Storage.Queues" Version="12.16.0" />
14+
<PackageVersion Include="Blazor.LocalStorage.WebAssembly" Version="8.0.0-rc.2.23480.2" />
15+
<PackageVersion Include="Blazor.SessionStorage.WebAssembly" Version="8.0.0-rc.2.23480.2" />
16+
<PackageVersion Include="Blazor.SpeechRecognition.WebAssembly" Version="8.0.0-rc.2.23480.2" />
17+
<PackageVersion Include="Blazor.SpeechSynthesis.WebAssembly" Version="8.0.0-rc.2.23480.2" />
18+
<PackageVersion Include="bunit" Version="1.24.10" />
19+
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
20+
<PackageVersion Include="Markdig" Version="0.33.0" />
21+
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0-beta3" />
22+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.2.23480.2" />
23+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0-rc.2.23480.2" />
24+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.2.23480.2" />
25+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
26+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
27+
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
28+
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.0" />
29+
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.0-rc.2.23480.2" />
30+
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0-rc.2.23479.6" />
31+
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0-rc.2.23479.6" />
32+
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
33+
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0-rc.2.23479.6" />
34+
<PackageVersion Include="Microsoft.ML" Version="2.0.1" />
35+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
36+
<PackageVersion Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
37+
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
38+
<PackageVersion Include="MudBlazor" Version="6.11.0" />
39+
<PackageVersion Include="PdfSharpCore" Version="1.3.62" />
40+
<PackageVersion Include="Pinecone.NET" Version="1.3.0" />
41+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
42+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
43+
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
44+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
45+
<PackageVersion Include="xunit" Version="2.5.2" />
46+
</ItemGroup>
47+
</Project>

app/Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
3+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
44
WORKDIR /app
5-
EXPOSE 80
5+
EXPOSE 8080
66
EXPOSE 443
77

8-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 AS build
8+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
99
WORKDIR /src
1010
COPY ["Directory.Build.props", "."]
11+
COPY ["Directory.Packages.props", "."]
1112
COPY ["backend/", "backend/"]
1213
COPY ["frontend/", "frontend/"]
1314
COPY ["shared/", "shared/"]

app/app.sln

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
..\.gitignore = ..\.gitignore
1414
..\.github\workflows\azure-dev.yml = ..\.github\workflows\azure-dev.yml
1515
Directory.Build.props = Directory.Build.props
16+
Directory.Packages.props = Directory.Packages.props
1617
..\.github\workflows\dotnet-build.yml = ..\.github\workflows\dotnet-build.yml
17-
global.json = global.json
1818
..\LICENSE = ..\LICENSE
19+
nuget.config = nuget.config
1920
..\README.md = ..\README.md
2021
EndProjectSection
2122
EndProject
@@ -25,7 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientApp.Tests", "tests\Cl
2526
EndProject
2627
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrepareDocs", "prepdocs\PrepareDocs\PrepareDocs.csproj", "{9C39AF95-2BB1-48CF-BD12-D214C0BD6076}"
2728
EndProject
28-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbedFunctions", "functions\EmbedFunctions\EmbedFunctions.csproj", "{54099AF3-CFA8-4EA9-9118-A26E3E63745B}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmbedFunctions", "functions\EmbedFunctions\EmbedFunctions.csproj", "{54099AF3-CFA8-4EA9-9118-A26E3E63745B}"
2930
EndProject
3031
Global
3132
GlobalSection(SolutionConfigurationPlatforms) = preSolution

app/backend/Extensions/SearchClientExtensions.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ internal static async Task<string> QueryDocumentsAsync(
3838
if (embedding != null && overrides?.RetrievalMode != "Text")
3939
{
4040
var k = useSemanticRanker ? 50 : top;
41-
var vectorQuery = new SearchQueryVector
41+
var vectorQuery = new RawVectorQuery
4242
{
4343
// if semantic ranker is enabled, we need to set the rank to a large number to get more
4444
// candidates for semantic reranking
4545
KNearestNeighborsCount = useSemanticRanker ? 50 : top,
46-
Value = embedding,
46+
Vector = embedding,
4747
};
4848
vectorQuery.Fields.Add("embedding");
49-
searchOption.Vectors.Add(vectorQuery);
49+
searchOption.VectorQueries.Add(vectorQuery);
5050
}
5151

52-
var searchResultResponse = await searchClient.SearchAsync<SearchDocument>(query, searchOption, cancellationToken);
52+
var searchResultResponse = await searchClient.SearchAsync<SearchDocument>(
53+
query, searchOption, cancellationToken);
5354
if (searchResultResponse.Value is null)
5455
{
5556
throw new InvalidOperationException("fail to get search result");

app/backend/GlobalUsings.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@
1313
global using Azure.Storage.Blobs.Models;
1414
global using Microsoft.AspNetCore.Mvc;
1515
global using Microsoft.AspNetCore.Mvc.RazorPages;
16-
global using Microsoft.ML;
17-
global using Microsoft.ML.Transforms.Text;
1816
global using Microsoft.SemanticKernel;
19-
global using Microsoft.SemanticKernel.AI;
17+
global using Microsoft.SemanticKernel.AI.ChatCompletion;
2018
global using Microsoft.SemanticKernel.AI.Embeddings;
21-
global using Microsoft.SemanticKernel.AI.TextCompletion;
22-
global using Microsoft.SemanticKernel.Memory;
23-
global using Microsoft.SemanticKernel.Orchestration;
2419
global using MinimalApi.Extensions;
2520
global using MinimalApi.Services;
2621
global using PdfSharpCore.Pdf;

0 commit comments

Comments
 (0)