Skip to content

Commit

Permalink
Add Framework build target and test for Azure functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Feb 12, 2025
1 parent 164df1d commit aa84496
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net481;net8.0;net9.0</TargetFrameworks>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -22,7 +22,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework)' == 'net9.0'"/>
<None Include="local.settings.json" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2020 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

#if NET9
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -34,3 +35,4 @@ public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ private static async Task Main(string[] args)


var host = new HostBuilder()
// the net8 target uses the "basic" azure function configuration
// the net481 and net8 target uses the "basic" azure function configuration
// the net9 target uses the aspnetcore azure function configuration
#if NET8_0
#if NETFRAMEWORK || NET8_0
.ConfigureFunctionsWorkerDefaults()
#elif NET9_0
.ConfigureFunctionsWebApplication()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,12 @@ public AzureFunctionHttpTriggerTestsCoreLatest(AzureFunctionApplicationFixtureHt
{
}
}

[NetFrameworkTest]
public class AzureFunctionHttpTriggerTestsFWLatest : AzureFunctionHttpTriggerTestsBase<AzureFunctionApplicationFixtureHttpTriggerFWLatest>
{
public AzureFunctionHttpTriggerTestsFWLatest(AzureFunctionApplicationFixtureHttpTriggerFWLatest fixture, ITestOutputHelper output)
: base(fixture, output, AzureFunctionHttpTriggerTestMode.SimpleInvocation)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public abstract class AzureFunctionApplicationFixture : RemoteApplicationFixture
private const string Priority = "1.23456";
private const string Timestamp = "1518469636025";

protected AzureFunctionApplicationFixture(string functionNames, string targetFramework, bool enableAzureFunctionMode)
: base(new AzureFuncTool(ApplicationDirectoryName, targetFramework, ApplicationType.Bounded, true, true, true, enableAzureFunctionMode))
protected AzureFunctionApplicationFixture(string functionNames, string targetFramework, bool enableAzureFunctionMode, bool isCoreApp = true)
: base(new AzureFuncTool(ApplicationDirectoryName, targetFramework, ApplicationType.Bounded, true, isCoreApp, true, enableAzureFunctionMode))
{
CommandLineArguments = $"start --no-build --language-worker dotnet-isolated --dotnet-isolated --functions {functionNames} ";

Expand Down Expand Up @@ -73,6 +73,13 @@ public AzureFunctionApplicationFixtureHttpTriggerCoreLatest() : base("httpTrigge
}
}

public class AzureFunctionApplicationFixtureHttpTriggerFWLatest : AzureFunctionApplicationFixture
{
public AzureFunctionApplicationFixtureHttpTriggerFWLatest() : base("httpTriggerFunctionUsingSimpleInvocation", "net481", true, false)
{
}
}

public class AzureFunctionApplicationFixtureInstrumentationDisabledCoreLatest : AzureFunctionApplicationFixture
{
public AzureFunctionApplicationFixtureInstrumentationDisabledCoreLatest() : base("httpTriggerFunctionUsingAspNetCorePipeline httpTriggerFunctionUsingSimpleInvocation", "net9.0", false)
Expand Down

0 comments on commit aa84496

Please sign in to comment.