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

Update .NET samples to .NET 8 and Minimal API #3017

Merged
merged 35 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1bdaff5
- Fix #387
isaacrlevin Nov 22, 2023
d88bc37
Updates to tests and packages
isaacrlevin Nov 23, 2023
a997796
Updated Csharp API
isaacrlevin Nov 23, 2023
6b3a726
Updated Todo Cosmos sample
isaacrlevin Nov 23, 2023
d8f6110
Updated Todo SQL Sample
isaacrlevin Nov 23, 2023
c971dfb
Updates per @davidfowl
isaacrlevin Nov 23, 2023
2a7a43e
Fix DI nit
isaacrlevin Nov 23, 2023
3a01318
update engsys to net8
vhvb1989 Nov 27, 2023
da4175b
update .net version
vhvb1989 Nov 27, 2023
d815468
- Rename files
isaacrlevin Nov 27, 2023
411badc
updates for new container
vhvb1989 Nov 28, 2023
1420015
npm
vhvb1989 Nov 28, 2023
f54b393
- Update READMEs
isaacrlevin Nov 28, 2023
e806000
Revert old template per @jongio
isaacrlevin Dec 1, 2023
1cdf01d
fix node installation
vhvb1989 Dec 1, 2023
adb800c
remove comment
vhvb1989 Dec 1, 2023
52d8643
Revert change and fix Create item bug
isaacrlevin Dec 4, 2023
68b3cbe
devcontiner for projects
vhvb1989 Dec 5, 2023
f6b59c0
devcontainer for func
vhvb1989 Dec 5, 2023
7978906
Update Azure Functions issue
isaacrlevin Dec 7, 2023
e581048
Revert "Update Azure Functions issue"
isaacrlevin Dec 7, 2023
62d3402
Fix Azure Function issue
isaacrlevin Dec 7, 2023
b607923
Fix Azure Function input issue
isaacrlevin Dec 8, 2023
076112e
Merge branch 'main' of https://github.com/Azure/azure-dev into Azure-…
isaacrlevin Dec 8, 2023
a6d4472
Merge branch 'Azure-main' into fix-387
isaacrlevin Dec 8, 2023
7efb267
Merge branch 'main' of github.com:Azure/azure-dev into fix-387
vhvb1989 Dec 11, 2023
404b4a8
Merge branch 'main' of github.com:Azure/azure-dev into fix-387
vhvb1989 Dec 11, 2023
f719b40
removes dockerfile for functions-core-tools
vhvb1989 Dec 12, 2023
0ed8070
Merge branch 'fix-387' of github.com:isaacrlevin/azure-dev into fix-387
vhvb1989 Dec 12, 2023
8ffdfe4
update user
vhvb1989 Dec 12, 2023
df13f61
missing yes
vhvb1989 Dec 12, 2023
275b5de
sync to usr bin
vhvb1989 Dec 12, 2023
cccd1ed
Merge branch 'main' of github.com:Azure/azure-dev into fix-387
vhvb1989 Dec 12, 2023
014df1b
use cp
vhvb1989 Dec 13, 2023
2c5a441
Merge branch 'main' of github.com:Azure/azure-dev into fix-387
vhvb1989 Dec 13, 2023
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
9 changes: 4 additions & 5 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:6.0
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:8.0

WORKDIR /app

Expand All @@ -17,11 +17,10 @@ RUN export DEBIAN_FRONTEND=noninteractive \
# az cli
&& curl -sSL https://aka.ms/InstallAzureCLIDeb | bash \
# nodejs
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
#&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs gcc g++ make npm\
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
# python
&& apt-get install -y --no-install-recommends python3-pip python-dev python3-venv \
&& python3 -m pip install --upgrade pip \
&& apt-get install -y --no-install-recommends python3-pip python3-venv \
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
&& echo 'alias python=python3' >> ~/.bashrc \
&& echo 'alias pip=pip3' >> ~/.bashrc \
# java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
isaacrlevin marked this conversation as resolved.
Show resolved Hide resolved
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/pkg/project/framework_service_dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (dp *dotnetProject) Build(
buildOutputDir = filepath.Join(buildOutputDir, defaultOutputDir)
}

// By default dotnet build will create a sub folder for the project framework version, etc. net6.0
// By default dotnet build will create a sub folder for the project framework version, etc. net8.0
// If we have a single folder under build configuration assume this location as build output result
subDirs, err := os.ReadDir(buildOutputDir)
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/pkg/project/framework_service_dotnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func Test_DotNetProject_Build(t *testing.T) {
dotNetCli := dotnet.NewDotNetCli(mockContext.CommandRunner)
serviceConfig := createTestServiceConfig("./src/api", AppServiceTarget, ServiceLanguageCsharp)

buildOutputDir := filepath.Join(serviceConfig.Path(), "bin", "Release", "net6.0")
buildOutputDir := filepath.Join(serviceConfig.Path(), "bin", "Release", "net8.0")
isaacrlevin marked this conversation as resolved.
Show resolved Hide resolved
err = os.MkdirAll(buildOutputDir, osutil.PermissionDirectory)
require.NoError(t, err)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy everything
Expand All @@ -9,7 +9,7 @@ RUN dotnet restore
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 3100
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource web 'Microsoft.Web/sites@2022-03-01' = {
serverFarmId: appServicePlan.id
httpsOnly: true
siteConfig: {
linuxFxVersion: 'DOTNETCORE|6.0'
linuxFxVersion: 'DOTNETCORE|8.0'
}
}
identity: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ stages:
dockerVersion: 17.09.0-ce
releaseType: stable

# Live testing uses dotnet 6.0.x in the WebApp project deployment
# Live testing uses dotnet 8.0.x in the WebApp project deployment
- task: UseDotNet@2
condition: and(succeeded(), ne(variables['Skip.LiveTest'], 'true'))
inputs:
version: 6.0.x
version: 8.0.x

- template: /eng/pipelines/templates/steps/az-login.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": {
"dockerfile": "Dockerfile",
"args": {
"IMAGE": "dotnet:6.0-bullseye"
"IMAGE": "dotnet:8.0-bullseye"
}
},
"features": {
Expand Down
184 changes: 0 additions & 184 deletions templates/todo/api/csharp-cosmos-sql/ListsController.cs

This file was deleted.

77 changes: 37 additions & 40 deletions templates/todo/api/csharp-cosmos-sql/Program.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
using Azure.Identity;
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
using Microsoft.Azure.Cosmos;
using SimpleTodo.Api;

var credential = new DefaultAzureCredential();
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton<ListsRepository>();
builder.Services.AddSingleton(_ => new CosmosClient(builder.Configuration["AZURE_COSMOS_ENDPOINT"], credential, new CosmosClientOptions()
{
SerializerOptions = new CosmosSerializationOptions
{
PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
}
}));
builder.Services.AddControllers();
builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);

var app = builder.Build();

app.UseCors(policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
});

// Swagger UI
app.UseSwaggerUI(options => {
options.SwaggerEndpoint("./openapi.yaml", "v1");
options.RoutePrefix = "";
});

app.UseStaticFiles(new StaticFileOptions{
// Serve openapi.yaml file
ServeUnknownFileTypes = true,
});

app.MapControllers();
using Azure.Identity;
using Microsoft.Azure.Cosmos;
using SimpleTodo.Api;

var builder = WebApplication.CreateBuilder(args);
var credential = new DefaultAzureCredential();
builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential);

builder.Services.AddSingleton<ListsRepository>();
builder.Services.AddSingleton(_ => new CosmosClient(builder.Configuration[builder.Configuration["AZURE_COSMOS_CONNECTION_STRING_KEY"]]));
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
isaacrlevin marked this conversation as resolved.
Show resolved Hide resolved
builder.Services.AddCors();
builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();

app.UseCors(policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
});

// Swagger UI
app.UseSwaggerUI(options => {
options.SwaggerEndpoint("./openapi.yaml", "v1");
options.RoutePrefix = "";
});

app.UseStaticFiles(new StaticFileOptions{
// Serve openapi.yaml file
ServeUnknownFileTypes = true,
});

app.MapGroup("/lists")
.MapTodoApi()
.WithOpenApi();
app.Run();
Loading