Skip to content

Commit

Permalink
Example function
Browse files Browse the repository at this point in the history
  • Loading branch information
Christdej authored and tsundvoll committed Aug 15, 2024
1 parent ef62d5e commit 261e2ae
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.2",
"commands": [
"dotnet-csharpier"
],
"rollForward": false
}
}
}
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# Azure Functions localsettings file
local.settings.json

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio Code
*.vscode
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Inspection Data Analyzer

IDA (Inspection Data Analyzer) is a repository for running pipelines to analyze data coming from various inspections.

See [LocalFunctionProj](./functions/LocalFunctionProj/) for an example of how to set up your pipeline. You can also run this function locally by running
'func start' from the [LocalFunctionProj](./functions/LocalFunctionProj/) folder, and then going to 'http://localhost:7071/api/HttpExample' to trigger it.

If you get 'Can't determine Project to build. Expected 1 .csproj or .fsproj but found 2' run 'dotnet clean' before running 'func start'
24 changes: 24 additions & 0 deletions functions/LocalFunctionProj/HttpExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LocalFunctionProj
{
public class HttpExample
{
private readonly ILogger<HttpExample> _logger;

public HttpExample(ILogger<HttpExample> logger)
{
_logger = logger;
}

[Function("HttpExample")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
return new OkObjectResult("Welcome to Azure Functions!");
}
}
}
30 changes: 30 additions & 0 deletions functions/LocalFunctionProj/LocalFunctionProj.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
</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>
13 changes: 13 additions & 0 deletions functions/LocalFunctionProj/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;

var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services => {
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();

host.Run();
9 changes: 9 additions & 0 deletions functions/LocalFunctionProj/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"LocalFunctionProj": {
"commandName": "Project",
"commandLineArgs": "--port 7225",
"launchBrowser": false
}
}
}
12 changes: 12 additions & 0 deletions functions/LocalFunctionProj/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
}
}
}
49 changes: 49 additions & 0 deletions inspection-data-analyzer.generated.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "functions", "functions", "{B1D2F182-23F6-459F-BF01-87E2D8C3CB94}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LocalFunctionProj", "functions\LocalFunctionProj\LocalFunctionProj.csproj", "{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LocalFunctionProj (1)", "LocalFunctionProj", "{E7281C8F-1AD5-482B-8AA0-BA3259CF6ADE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "obj", "obj", "{DFE56E78-7B76-4B0B-B1D5-E7C8E781D455}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{89F25B0E-8C72-4669-9096-FE5B2138CFD7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{8BC2E56E-C9F6-42A5-A21F-F36360A62363}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerExtensions", "functions\LocalFunctionProj\obj\Debug\net8.0\WorkerExtensions\WorkerExtensions.csproj", "{70B7510F-F208-4C37-A89F-55684C105315}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE}.Release|Any CPU.Build.0 = Release|Any CPU
{70B7510F-F208-4C37-A89F-55684C105315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70B7510F-F208-4C37-A89F-55684C105315}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70B7510F-F208-4C37-A89F-55684C105315}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70B7510F-F208-4C37-A89F-55684C105315}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8CA9CB1C-85B3-49CD-903A-FC7EEB6BCADE} = {B1D2F182-23F6-459F-BF01-87E2D8C3CB94}
{E7281C8F-1AD5-482B-8AA0-BA3259CF6ADE} = {B1D2F182-23F6-459F-BF01-87E2D8C3CB94}
{DFE56E78-7B76-4B0B-B1D5-E7C8E781D455} = {E7281C8F-1AD5-482B-8AA0-BA3259CF6ADE}
{89F25B0E-8C72-4669-9096-FE5B2138CFD7} = {DFE56E78-7B76-4B0B-B1D5-E7C8E781D455}
{8BC2E56E-C9F6-42A5-A21F-F36360A62363} = {89F25B0E-8C72-4669-9096-FE5B2138CFD7}
{70B7510F-F208-4C37-A89F-55684C105315} = {8BC2E56E-C9F6-42A5-A21F-F36360A62363}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA9FF531-4FA9-427C-A1DA-1FBA102D096D}
EndGlobalSection
EndGlobal

0 comments on commit 261e2ae

Please sign in to comment.