Skip to content

Commit

Permalink
Added function template
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed Jul 3, 2019
1 parent 0233e3e commit 28e3a0e
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 7 deletions.
15 changes: 15 additions & 0 deletions Templates.sln
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Web", "templ
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Templates", "templates\Rocket.Surgery.Templates.csproj", "{59B51B1F-ED6D-4EFB-B1F6-479532638CFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.Functions", "templates\Function\Rocket.Surgery.Functions.csproj", "{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -128,6 +130,18 @@ Global
{59B51B1F-ED6D-4EFB-B1F6-479532638CFF}.Release|x64.Build.0 = Release|Any CPU
{59B51B1F-ED6D-4EFB-B1F6-479532638CFF}.Release|x86.ActiveCfg = Release|Any CPU
{59B51B1F-ED6D-4EFB-B1F6-479532638CFF}.Release|x86.Build.0 = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|x64.ActiveCfg = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|x64.Build.0 = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|x86.ActiveCfg = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Debug|x86.Build.0 = Debug|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|Any CPU.Build.0 = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|x64.ActiveCfg = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|x64.Build.0 = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|x86.ActiveCfg = Release|Any CPU
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -140,5 +154,6 @@ Global
{4B5B6606-AC5C-4FAB-9081-F49E215876D9} = {38ABF504-0DA2-41BA-B262-3E23746CBC3C}
{EBC8D6EE-EBF1-4AB3-9AD6-7B86F17276B5} = {38ABF504-0DA2-41BA-B262-3E23746CBC3C}
{2B6FD22D-064C-4B0E-9EFD-97F65784AB32} = {38ABF504-0DA2-41BA-B262-3E23746CBC3C}
{CB33D3D9-673C-4764-9B42-DBA3EBEA753A} = {38ABF504-0DA2-41BA-B262-3E23746CBC3C}
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions templates/Api/Rocket.Surgery.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Rocket.Surgery.Hosting" />
<PackageReference Include="Rocket.Surgery.Conventions" />
<PackageReference Include="Rocket.Surgery.Extensions" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" />
Expand All @@ -18,7 +17,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2-preview-0910" />
<PackageReference Include="Rocket.Surgery.Hosting" Version="4.0.0" />
<PackageReference Include="Rocket.Surgery.Conventions" Version="6.2.2" />
<PackageReference Include="Rocket.Surgery.Extensions" Version="1.0.1" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" Version="5.0.4" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" Version="6.0.3" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" Version="6.0.3" />
Expand Down
2 changes: 0 additions & 2 deletions templates/Cli/Rocket.Surgery.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<!--#if (no-version)
<PackageReference Include="Rocket.Surgery.Hosting" />
<PackageReference Include="Rocket.Surgery.Conventions" />
<PackageReference Include="Rocket.Surgery.Extensions" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" />
Expand All @@ -17,7 +16,6 @@
<!--#if (!no-version) -->
<PackageReference Include="Rocket.Surgery.Hosting" Version="4.0.0" />
<PackageReference Include="Rocket.Surgery.Conventions" Version="6.2.2" />
<PackageReference Include="Rocket.Surgery.Extensions" Version="1.0.1" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" Version="5.0.4" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" Version="6.0.3" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" Version="6.0.3" />
Expand Down
2 changes: 1 addition & 1 deletion templates/Function/.template.confg/template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "David Driscoll",
"classifications": [ "Common", "Functions", "Rocket Surgery" ],
"classifications": [ "Common", "Function", "Rocket Surgery" ],
"identity": "Rocket.Surgery.Functions",
"name": "Rocket Surgery Azure Functions Application",
"shortName": "rocketfunction",
Expand Down
25 changes: 25 additions & 0 deletions templates/Function/Function.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Rocket.Surgery.Functions
{
public class Function
{
private readonly ILogger _logger;

public Function(ILogger<Function> logger) => _logger = logger;

[FunctionName("Function")]
public ActionResult<int> Run([HttpTrigger("get")]HttpRequest context, ILogger logger)
{
logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

return 1;
}
}
}
35 changes: 35 additions & 0 deletions templates/Function/Rocket.Surgery.Functions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<!--#if (no-version)
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
<PackageReference Include="Rocket.Surgery.Hosting.Functions" />
<PackageReference Include="Rocket.Surgery.Conventions" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" />
<PackageReference Include="Rocket.Surgery.Extensions.Logging" />
#endif -->
<!--#if (!no-version) -->
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Rocket.Surgery.Hosting.Functions" Version="4.0.0" />
<PackageReference Include="Rocket.Surgery.Conventions" Version="6.2.2" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" Version="6.0.3" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" Version="6.0.3" />
<PackageReference Include="Rocket.Surgery.Extensions.Logging" Version="6.0.3" />
<!--#endif -->
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
29 changes: 29 additions & 0 deletions templates/Function/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Rocket.Surgery.Extensions.DependencyInjection;
using Rocket.Surgery.Hosting.Functions;

[assembly: WebJobsStartup(typeof(Rocket.Surgery.Functions.Startup))]

namespace Rocket.Surgery.Functions
{
public class Startup : IWebJobsStartup, IServiceConvention
{
public void Register(IServiceConventionContext context)
{
}

public void Configure(IWebJobsBuilder builder)
{
builder.UseRocketSurgery(
this,
hostBuilder =>
{
});
}
}
}
3 changes: 3 additions & 0 deletions templates/Function/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "2.0"
}
7 changes: 7 additions & 0 deletions templates/Function/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
2 changes: 0 additions & 2 deletions templates/GenericHost/Rocket.Surgery.GenericHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<!--#if (no-version)
<PackageReference Include="Rocket.Surgery.Hosting" />
<PackageReference Include="Rocket.Surgery.Conventions" />
<PackageReference Include="Rocket.Surgery.Extensions" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" />
Expand All @@ -17,7 +16,6 @@
<!--#if (!no-version) -->
<PackageReference Include="Rocket.Surgery.Hosting" Version="4.0.0" />
<PackageReference Include="Rocket.Surgery.Conventions" Version="6.2.2" />
<PackageReference Include="Rocket.Surgery.Extensions" Version="1.0.1" />
<PackageReference Include="Rocket.Surgery.Extensions.CommandLine" Version="5.0.4" />
<PackageReference Include="Rocket.Surgery.Extensions.Configuration" Version="6.0.3" />
<PackageReference Include="Rocket.Surgery.Extensions.DependencyInjection" Version="6.0.3" />
Expand Down

0 comments on commit 28e3a0e

Please sign in to comment.