Skip to content

Commit

Permalink
Added host.json when using UseAppSettings extension to be used by Azu…
Browse files Browse the repository at this point in the history
…re Functions settings (#7)

* Adding exception to not publish when there is a documentation change.
* Fix deploy workflow
* Update packages, add host.json to configuration.
  • Loading branch information
junalmeida authored Sep 8, 2020
1 parent 2effd3a commit 49ed6d8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ public static IFunctionsHostBuilder UseAppSettings(this IFunctionsHostBuilder ho
string currentDirectory = fileInfo.Directory.Parent.FullName;

var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (string.IsNullOrWhiteSpace(environment)) environment = "Development";
if (string.IsNullOrWhiteSpace(environment))
environment = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
if (string.IsNullOrWhiteSpace(environment))
environment = "Development"; // Fallback to Development when none is set.

return UseAppSettings(hostBuilder, (builder) =>
{
builder
.SetBasePath(currentDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddJsonFile("host.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
});
}
Expand Down
4 changes: 2 additions & 2 deletions SampleAutofacFunction/SampleAutofacFunction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Autofac.Extensions.DependencyInjection.AzureFunctions\Autofac.Extensions.DependencyInjection.AzureFunctions.csproj" />
Expand Down
3 changes: 2 additions & 1 deletion SampleAutofacFunction/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"isEnabled": true
}
}
}
},
"functionTimeout": "00:10:00"
}
1 change: 1 addition & 0 deletions autofac-azurefunctions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE = LICENSE
.github\workflows\main.yml = .github\workflows\main.yml
README.md = README.md
EndProjectSection
EndProject
Expand Down

0 comments on commit 49ed6d8

Please sign in to comment.