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

feat: Added azure functions support #8

Closed
wants to merge 9 commits into from
Closed
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
6 changes: 5 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Core" Version="1.13.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
<PackageVersion Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
Expand All @@ -20,4 +24,4 @@
<PackageVersion Include="xunit.runner.console" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
</ItemGroup>
</Project>
</Project>
34 changes: 34 additions & 0 deletions Http.Correlation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Http.Correlation.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Http.Correlation.HttpClient.Tests.Unit", "tests\NetEvolve.Http.Correlation.HttpClient.Tests.Unit\NetEvolve.Http.Correlation.HttpClient.Tests.Unit.csproj", "{15F2CFB5-C89E-4F93-86E8-F20B98DDC7AC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Http.Correlation.Functions", "src\NetEvolve.Http.Correlation.Functions\NetEvolve.Http.Correlation.Functions.csproj", "{4D933E7A-4828-4BAA-AE47-CE032D5B8973}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Http.Correlation.Functions.Tests.Unit", "tests\NetEvolve.Http.Correlation.Functions.Tests.Unit\NetEvolve.Http.Correlation.Functions.Tests.Unit.csproj", "{20994B9E-C3F1-4400-AB82-B569753BB17F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{A85D3A46-4B31-4451-B7CE-4CCD59A5A903}"
ProjectSection(SolutionItems) = preProject
sample\Directory.Build.props = sample\Directory.Build.props
sample\Directory.Packages.props = sample\Directory.Packages.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.WebApi.NET7", "sample\Sample.WebApi.NET7\Sample.WebApi.NET7.csproj", "{EB620E13-40E6-4147-95BE-34F26FB67A6C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.WebApi.NET6", "sample\Sample.WebApi.NET6\Sample.WebApi.NET6.csproj", "{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -88,6 +102,22 @@ Global
{15F2CFB5-C89E-4F93-86E8-F20B98DDC7AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15F2CFB5-C89E-4F93-86E8-F20B98DDC7AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15F2CFB5-C89E-4F93-86E8-F20B98DDC7AC}.Release|Any CPU.Build.0 = Release|Any CPU
{4D933E7A-4828-4BAA-AE47-CE032D5B8973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D933E7A-4828-4BAA-AE47-CE032D5B8973}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D933E7A-4828-4BAA-AE47-CE032D5B8973}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D933E7A-4828-4BAA-AE47-CE032D5B8973}.Release|Any CPU.Build.0 = Release|Any CPU
{20994B9E-C3F1-4400-AB82-B569753BB17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20994B9E-C3F1-4400-AB82-B569753BB17F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20994B9E-C3F1-4400-AB82-B569753BB17F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20994B9E-C3F1-4400-AB82-B569753BB17F}.Release|Any CPU.Build.0 = Release|Any CPU
{EB620E13-40E6-4147-95BE-34F26FB67A6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB620E13-40E6-4147-95BE-34F26FB67A6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB620E13-40E6-4147-95BE-34F26FB67A6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB620E13-40E6-4147-95BE-34F26FB67A6C}.Release|Any CPU.Build.0 = Release|Any CPU
{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -101,6 +131,10 @@ Global
{AB2142E3-0EB7-4E37-B3D7-CF11B540A9B3} = {966730BD-654E-4160-B960-1913EAA151CA}
{6A992CD1-15F8-4BC3-98E6-0492C638C2D8} = {DCCA63A9-B066-4B95-AD66-20DE5F372403}
{15F2CFB5-C89E-4F93-86E8-F20B98DDC7AC} = {966730BD-654E-4160-B960-1913EAA151CA}
{4D933E7A-4828-4BAA-AE47-CE032D5B8973} = {DCCA63A9-B066-4B95-AD66-20DE5F372403}
{20994B9E-C3F1-4400-AB82-B569753BB17F} = {966730BD-654E-4160-B960-1913EAA151CA}
{EB620E13-40E6-4147-95BE-34F26FB67A6C} = {A85D3A46-4B31-4451-B7CE-4CCD59A5A903}
{033D1201-E3EB-4AD6-AF81-FDE2330ED0F5} = {A85D3A46-4B31-4451-B7CE-4CCD59A5A903}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6EA9C0B3-11F7-4677-A2CF-6A4F280BA2A5}
Expand Down
9 changes: 9 additions & 0 deletions sample/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>

</Project>
8 changes: 8 additions & 0 deletions sample/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace Sample.WebApi.NET6.Controllers;

Check failure on line 1 in sample/Sample.WebApi.NET6/Controllers/WeatherForecastController.cs

View workflow job for this annotation

GitHub Actions / Build & Tests / Format / Validate Code Formatting

Fix imports ordering.

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] _summaries = new[]
{
"Freezing",
"Bracing",
"Chilly",
"Cool",
"Mild",
"Warm",
"Balmy",
"Hot",
"Sweltering",
"Scorching"
};

public WeatherForecastController() { }

[HttpGet]
[SuppressMessage(
"Security",
"CA5394:Do not use insecure randomness",
Justification = "As designed."
)]
public IEnumerable<WeatherForecast> Get() =>
Enumerable
.Range(1, 5)
.Select(
index =>
new WeatherForecast
{
Date = DateTime.UtcNow.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = _summaries[Random.Shared.Next(_summaries.Length)]
}
)
.ToArray();
}
32 changes: 32 additions & 0 deletions sample/Sample.WebApi.NET6/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Sample.WebApi.NET6;

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using NetEvolve.Http.Correlation;

public static class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
_ = builder.Services.AddControllers();

// Add Http correlation support
_ = builder.Services.AddHttpCorrelation().WithGuidGenerator();

var app = builder.Build();

// Configure the HTTP request pipeline.
_ = app.UseHttpCorrelation();

_ = app.UseHttpsRedirection();

_ = app.UseAuthorization();

_ = app.MapControllers();

app.Run();
}
}
31 changes: 31 additions & 0 deletions sample/Sample.WebApi.NET6/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:30976",
"sslPort": 44320
}
},
"profiles": {
"Sample.WebApi.NET6": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:7269;http://localhost:5199",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
11 changes: 11 additions & 0 deletions sample/Sample.WebApi.NET6/Sample.WebApi.NET6.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NetEvolve.Http.Correlation.AspNetCore\NetEvolve.Http.Correlation.AspNetCore.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions sample/Sample.WebApi.NET6/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Sample.WebApi.NET6;

using System;

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }
}
8 changes: 8 additions & 0 deletions sample/Sample.WebApi.NET6/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions sample/Sample.WebApi.NET6/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace Sample.WebApi.NET7.Controllers;

Check failure on line 1 in sample/Sample.WebApi.NET7/Controllers/WeatherForecastController.cs

View workflow job for this annotation

GitHub Actions / Build & Tests / Format / Validate Code Formatting

Fix imports ordering.

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] _summaries = new[]
{
"Freezing",
"Bracing",
"Chilly",
"Cool",
"Mild",
"Warm",
"Balmy",
"Hot",
"Sweltering",
"Scorching"
};

public WeatherForecastController() { }

[HttpGet]
[SuppressMessage(
"Security",
"CA5394:Do not use insecure randomness",
Justification = "As designed."
)]
public IEnumerable<WeatherForecast> Get() =>
Enumerable
.Range(1, 5)
.Select(
index =>
new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.UtcNow.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = _summaries[Random.Shared.Next(_summaries.Length)]
}
)
.ToArray();
}
32 changes: 32 additions & 0 deletions sample/Sample.WebApi.NET7/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Sample.WebApi.NET7;

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using NetEvolve.Http.Correlation;

public static class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
_ = builder.Services.AddControllers();

// Add Http correlation support
_ = builder.Services.AddHttpCorrelation().WithGuidGenerator();

var app = builder.Build();

// Configure the HTTP request pipeline.
_ = app.UseHttpCorrelation();

_ = app.UseHttpsRedirection();

_ = app.UseAuthorization();

_ = app.MapControllers();

app.Run();
}
}
41 changes: 41 additions & 0 deletions sample/Sample.WebApi.NET7/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:42861",
"sslPort": 44381
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5114",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:7203;http://localhost:5114",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
11 changes: 11 additions & 0 deletions sample/Sample.WebApi.NET7/Sample.WebApi.NET7.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NetEvolve.Http.Correlation.AspNetCore\NetEvolve.Http.Correlation.AspNetCore.csproj" />
</ItemGroup>

</Project>
Loading
Loading