Skip to content

Commit

Permalink
setup azure function sut
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsonax committed Dec 12, 2023
1 parent 085fd51 commit 7928550
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ csharp_style_namespace_declarations = file_scoped:warning
dotnet_sort_system_directives_first = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
csharp_style_prefer_primary_constructors = false

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
Expand Down
26 changes: 26 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/AzureFunction.Sut.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0"/>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1"/>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext"/>
</ItemGroup>
</Project>
32 changes: 32 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/HttpTrigger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace AzureFunction.Sut;

public class HttpTrigger
{
private readonly ILogger _logger;

public HttpTrigger(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<HttpTrigger>();
}

[Function("HttpTrigger")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
FunctionContext executionContext)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");

var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");

response.WriteString("Welcome to Azure Functions!");

return response;

}
}
4 changes: 4 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/HttpTrigger.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@host=http://localhost:7071

### api/HttpTrigger1
GET {{host}}/api/HttpTrigger
7 changes: 7 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();

host.Run();
12 changes: 12 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}
7 changes: 7 additions & 0 deletions Examples/AzureFunction/AzureFunction.Sut/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
10 changes: 10 additions & 0 deletions TestExamplesDotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "Vue.Frontend.Sut", "Example
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestExamplesDotnet.EntityFrameworkCore", "TestExamplesDotnet.EntityFrameworkCore\TestExamplesDotnet.EntityFrameworkCore.csproj", "{A8EF269C-4C15-424E-AB00-FD4F7B0B5F13}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AzureFunction", "AzureFunction", "{E700E671-F1E6-48BE-8771-35976CB26E5D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFunction.Sut", "Examples\AzureFunction\AzureFunction.Sut\AzureFunction.Sut.csproj", "{E3FD6459-8DFF-4555-8B22-8B653E01F79F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -193,6 +197,10 @@ Global
{A8EF269C-4C15-424E-AB00-FD4F7B0B5F13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8EF269C-4C15-424E-AB00-FD4F7B0B5F13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8EF269C-4C15-424E-AB00-FD4F7B0B5F13}.Release|Any CPU.Build.0 = Release|Any CPU
{E3FD6459-8DFF-4555-8B22-8B653E01F79F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3FD6459-8DFF-4555-8B22-8B653E01F79F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3FD6459-8DFF-4555-8B22-8B653E01F79F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3FD6459-8DFF-4555-8B22-8B653E01F79F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -224,6 +232,8 @@ Global
{C71FF336-C9C8-4883-A8BF-521F6C378631} = {954C3F42-2996-4570-8483-F65993B6B80D}
{122D8E51-7E45-4C83-BF43-15868214DF6A} = {954C3F42-2996-4570-8483-F65993B6B80D}
{13FE5A2F-CA1A-4B83-B82E-C05B679DD0DD} = {42CF9A64-C1CC-4F8A-91EC-D46B948F0BF6}
{E700E671-F1E6-48BE-8771-35976CB26E5D} = {FB8382F9-4F4C-4080-ACD6-7112A55C2D65}
{E3FD6459-8DFF-4555-8B22-8B653E01F79F} = {E700E671-F1E6-48BE-8771-35976CB26E5D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84A1D680-ABEE-46A5-B342-CD8C47FC5AB0}
Expand Down

0 comments on commit 7928550

Please sign in to comment.