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 sample v4 in-process functions to .NET 8 #273

Merged
merged 1 commit into from
Nov 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
sudo apt-get install azure-functions-core-tools-4
func version
# See https://github.com/Azure/azure-functions-core-tools/issues/3766
sudo chmod +x /usr/lib/azure-functions-core-tools-4/in-proc6/func
sudo chmod +x /usr/lib/azure-functions-core-tools-4/in-proc8/func
- name: Build
id: build
run: |
Expand Down
186 changes: 89 additions & 97 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"Host": {
"type": "string",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"ExecutableTarget": {
"type": "string",
"enum": [
"AppInsightsConnectionStringIntegrationTest",
"Clean",
"Compile",
"GenerateCoverage",
"IntegrationTest",
"Pack",
"PublishFunctions",
"Restore",
"RestoreAppInsightsConnectionStringUserSecrets",
"RestoreUserSecrets",
"SetAppInsightsConnectionStringIntegrationTestUserSecrets",
"SetGitHubVersion",
"SetIntegrationTestUserSecrets",
"SetShouldWeRunIntegrationTests",
"StartAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StartIntegrationTestAzureFunctions",
"StopAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StopIntegrationTestAzureFunctions",
"UnitTest",
"VerifyFormat",
"WriteAppInsightsConnectionStringIntegrationTestAzureFunctionLogs",
"WriteIntegrationTestAzureFunctionLogs"
]
},
"Verbosity": {
"type": "string",
"description": "",
"enum": [
"Verbose",
"Normal",
"Minimal",
"Quiet"
]
},
"NukeBuild": {
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
Expand All @@ -23,37 +69,13 @@
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"IntegrationTestServiceBusConnectionString": {
"type": "string"
"$ref": "#/definitions/Host"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"Package": {
"type": "boolean",
"description": "Whether we publish the sample Functions to file system - Default is false"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
Expand All @@ -77,79 +99,49 @@
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"AppInsightsConnectionStringIntegrationTest",
"Clean",
"Compile",
"GenerateCoverage",
"IntegrationTest",
"Pack",
"PublishFunctions",
"Restore",
"RestoreAppInsightsConnectionStringUserSecrets",
"RestoreUserSecrets",
"SetAppInsightsConnectionStringIntegrationTestUserSecrets",
"SetGitHubVersion",
"SetIntegrationTestUserSecrets",
"SetShouldWeRunIntegrationTests",
"StartAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StartIntegrationTestAzureFunctions",
"StopAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StopIntegrationTestAzureFunctions",
"UnitTest",
"VerifyFormat",
"WriteAppInsightsConnectionStringIntegrationTestAzureFunctionLogs",
"WriteIntegrationTestAzureFunctionLogs"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"AppInsightsConnectionStringIntegrationTest",
"Clean",
"Compile",
"GenerateCoverage",
"IntegrationTest",
"Pack",
"PublishFunctions",
"Restore",
"RestoreAppInsightsConnectionStringUserSecrets",
"RestoreUserSecrets",
"SetAppInsightsConnectionStringIntegrationTestUserSecrets",
"SetGitHubVersion",
"SetIntegrationTestUserSecrets",
"SetShouldWeRunIntegrationTests",
"StartAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StartIntegrationTestAzureFunctions",
"StopAppInsightsConnectionStringIntegrationTestAzureFunctions",
"StopIntegrationTestAzureFunctions",
"UnitTest",
"VerifyFormat",
"WriteAppInsightsConnectionStringIntegrationTestAzureFunctionLogs",
"WriteIntegrationTestAzureFunctionLogs"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"$ref": "#/definitions/Verbosity"
}
}
}
},
"allOf": [
{
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
"Debug",
"Release"
]
},
"IntegrationTestServiceBusConnectionString": {
"type": "string"
},
"Package": {
"type": "boolean",
"description": "Whether we publish the sample Functions to file system - Default is false"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
}
}
},
{
"$ref": "#/definitions/NukeBuild"
}
}
]
}
7 changes: 4 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="3.1.32" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" Condition="'$(TargetFramework)' == 'net6.0'" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.16.4" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="3.1.32" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" Condition="'$(TargetFramework)' == 'net6.0'" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="3.1.2" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.3.0" Condition="'$(TargetFramework)' == 'net6.0'" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.4.0" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TargetFramework)' == 'net6.0'" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="xunit.analyzers" Version="1.17.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19" />
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ NuGet packages:

- `Microsoft.NET.Sdk.Functions`:
- `v3`: `3.1.2` (added automatically when creating the Function, updated later)
- `v4`: `4.1.3` (added automatically when creating the Function, updated later)
- `v4`: `4.4.0` (added automatically when creating the Function, updated later)
- `Microsoft.Azure.Functions.Extensions`: `1.1.0` (added manually following [Use dependency injection in .NET Azure Functions][dependency-injection])
- `Microsoft.Extensions.DependencyInjection` (added manually following [Use dependency injection in .NET Azure Functions][dependency-injection], updated later):
- `v3`: `3.1.32`
- `v4`: `6.0.1`
- `Microsoft.Azure.WebJobs.Logging.ApplicationInsights`: `3.0.35` (added manually following [Log custom telemetry in C# Azure Functions][custom-telemetry])
- `v4`: `8.0.0`
- `Microsoft.Azure.WebJobs.Logging.ApplicationInsights`: `3.0.41` (added manually following [Log custom telemetry in C# Azure Functions][custom-telemetry])

### Supporting telemetry processors

Expand Down
4 changes: 2 additions & 2 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ from framework in testProject.GetTargetFrameworks()
.Executes(() =>
{
ReportGeneratorTasks.ReportGenerator(s => s
.SetFramework("net6.0")
.SetFramework("net8.0")
.SetReports($"{TestResultsDirectory}/**/coverage.cobertura.xml")
.SetTargetDirectory(CodeCoverageDirectory)
.SetReportTypes(ReportTypes.Html));
Expand Down Expand Up @@ -494,7 +494,7 @@ static Action<OutputType, string> BuildLogger(ManualResetEventSlim slim, StringB
void StartFunction(string functionName, Action<OutputType, string> logger)
{
ProcessTasks
.StartProcess("func", "start --no-build", SamplesDirectory / functionName / "bin" / Configuration / "net6.0", null, null, null, null, logger);
.StartProcess("func", "start --no-build", SamplesDirectory / functionName / "bin" / Configuration / "net8.0", null, null, null, null, logger);
}

void RunIntegrationTest(string projectName)
Expand Down
1 change: 1 addition & 0 deletions deploy/functionApp.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ resource appSettings 'Microsoft.Web/sites/config@2022-03-01' = {
APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsightsConnectionString
FUNCTIONS_EXTENSION_VERSION: functionsExtensionsVersion
FUNCTIONS_WORKER_RUNTIME: functionWorkerRuntime
FUNCTIONS_INPROC_NET8_ENABLED: '1'
WEBSITE_CONTENTAZUREFILECONNECTIONSTRING: storageAccountConnectionString
WEBSITE_CONTENTSHARE: functionAppName
WEBSITE_RUN_FROM_PACKAGE: '1'
Expand Down
4 changes: 2 additions & 2 deletions deploy/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var functions = [
functionAppName: '${resourceNamePrefix}-${toLower(defaultV4InProcessFunctionDisplayName)}-func'
functionRuntimeVersion: 4
functionWorkerRuntime: 'dotnet'
dotnetVersion: 'v4.0'
dotnetVersion: 'v8.0'
storageName: '${resourceNamePrefix}7${toLower(defaultV4InProcessFunctionDisplayName)}'
}
{
Expand All @@ -66,7 +66,7 @@ var functions = [
functionAppName: '${resourceNamePrefix}-${toLower(customV4InProcessFunctionDisplayName)}-func'
functionRuntimeVersion: 4
functionWorkerRuntime: 'dotnet'
dotnetVersion: 'v4.0'
dotnetVersion: 'v8.0'
storageName: '${resourceNamePrefix}7${toLower(customV4InProcessFunctionDisplayName)}'
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion samples/CustomV4InProcessFunction/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override void Configure(IFunctionsHostBuilder builder)
{
var testingOptions = builder.GetContext().Configuration.GetSection("Testing").Get<TestingOptions>();

if (testingOptions.IsEnabled)
if (testingOptions?.IsEnabled == true)
{
builder.Services.AddSingleton<ITelemetryChannel, TestingChannel>();
}
Expand Down
1 change: 1 addition & 0 deletions samples/CustomV4InProcessFunction/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"FUNCTIONS_INPROC_NET8_ENABLED": "1",
"ServiceBusConnection": "",
"logging:logLevel:Microsoft.Azure.WebJobs.Script.WebHost.Middleware.SystemTraceMiddleware": "None",
"Testing:IsEnabled": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion samples/DefaultV4InProcessFunction/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void Configure(IFunctionsHostBuilder builder)
{
var testingOptions = builder.GetContext().Configuration.GetSection("Testing").Get<TestingOptions>();

if (testingOptions.IsEnabled)
if (testingOptions?.IsEnabled == true)
{
builder.Services.AddSingleton<ITelemetryChannel, TestingChannel>();
}
Expand Down
1 change: 1 addition & 0 deletions samples/DefaultV4InProcessFunction/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"FUNCTIONS_INPROC_NET8_ENABLED": "1",
"ServiceBusConnection": "",
"logging:logLevel:Microsoft.Azure.WebJobs.Script.WebHost.Middleware.SystemTraceMiddleware": "None",
"Testing:IsEnabled": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Loading
Loading