Browse Source

Added support for environment variables when using Azure Functions (#1171)

Co-authored-by: Chris Theodorson <chris.theodorson@halfords.co.uk>
pull/1190/head
Chris 4 years ago
committed by GitHub
parent
commit
e3e90d3baf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Microsoft.Tye.Core/ApplicationFactory.cs
  2. 3
      src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs
  3. 5
      src/tye/ApplicationBuilderExtensions.cs

4
src/Microsoft.Tye.Core/ApplicationFactory.cs

@ -403,6 +403,10 @@ namespace Microsoft.Tye
{
executable.EnvironmentVariables.Add(envVar);
}
else if (service is AzureFunctionServiceBuilder azureFunction)
{
azureFunction.EnvironmentVariables.Add(envVar);
}
else if (service is ExternalServiceBuilder)
{
throw new CommandException("External services do not support environment variables.");

3
src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs

@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Microsoft.Tye
{
public class AzureFunctionServiceBuilder : ServiceBuilder
@ -17,5 +19,6 @@ namespace Microsoft.Tye
public string FunctionPath { get; }
public string? FuncExecutablePath { get; set; }
public string? ProjectFile { get; set; }
public List<EnvironmentVariableBuilder> EnvironmentVariables { get; } = new List<EnvironmentVariableBuilder>();
}
}

5
src/tye/ApplicationBuilderExtensions.cs

@ -151,6 +151,11 @@ namespace Microsoft.Tye
replicas = function.Replicas;
liveness = null;
readiness = null;
foreach (var entry in function.EnvironmentVariables)
{
env.Add(entry.ToHostingEnvironmentVariable());
}
}
else
{

Loading…
Cancel
Save