Skip to content

Commit

Permalink
Fixed it so that it runs in Azure aswell
Browse files Browse the repository at this point in the history
  • Loading branch information
Dibran Mulder committed Oct 18, 2018
1 parent 677e46d commit 6344299
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/AzureFunctionsV2DI/Properties/PublishProfiles/AllegoDibranTestV2 - Web Deploy.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0-beta8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions AzureFunctionsV2DI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2016
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFunctionsV2DI", "AzureFunctionsV2DI\AzureFunctionsV2DI.csproj", "{F09C4202-2C7F-4FB0-AC83-42436B7437A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureFunctionsV2DI", "AzureFunctionsV2DI\AzureFunctionsV2DI.csproj", "{F09C4202-2C7F-4FB0-AC83-42436B7437A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFunctionsV2.DependencyInjection", "AzureFunctionsV2.DependencyInjection\AzureFunctionsV2.DependencyInjection.csproj", "{B9E54B38-88D4-4028-8EBC-7FD0586591D5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureFunctionsV2.DependencyInjection", "AzureFunctionsV2.DependencyInjection\AzureFunctionsV2.DependencyInjection.csproj", "{B9E54B38-88D4-4028-8EBC-7FD0586591D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
10 changes: 8 additions & 2 deletions AzureFunctionsV2DI/AzureFunctionsV2DI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.19" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.23" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AzureFunctionsV2.DependencyInjection\AzureFunctionsV2.DependencyInjection.csproj" />
Expand All @@ -13,9 +13,15 @@
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CopyTargetPathToEarlyPublish" BeforeTargets="Publish">
<Copy SourceFiles="$(TargetPath)" DestinationFiles="$(FunctionsTargetPath)" />
</Target>
</Project>
2 changes: 2 additions & 0 deletions AzureFunctionsV2DI/DemoFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static IActionResult Run(

var res = demoService.GetResponse();

log.LogInformation($"Res = {res}");

return new OkObjectResult(res);
}
}
Expand Down
12 changes: 4 additions & 8 deletions AzureFunctionsV2DI/WebJobsExtensionStartup.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using AzureFunctionsV2.DependencyInjection;
using AzureFunctionsV2.DependencyInjection;
using AzureFunctionsV2DI;
using AzureFunctionsV2DI.Service;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;

[assembly: WebJobsStartup(typeof(WebJobsExtensionStartup), "A Web Jobs Extension Sample")]
namespace AzureFunctionsV2DI
Expand All @@ -14,13 +14,9 @@ public class WebJobsExtensionStartup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
IConfigurationRoot config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var config = builder.Services.FirstOrDefault(p => p.ServiceType == typeof(IConfiguration))?.ImplementationInstance as IConfiguration;

var testValue = config.GetValue<string>("Test");
string testValue = config.GetValue<string>("Test");

builder.Services.AddSingleton<IDemoService>(new DemoService(testValue));

Expand Down
7 changes: 7 additions & 0 deletions FunctionApp1/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"
}
}

0 comments on commit 6344299

Please sign in to comment.