diff --git a/src/Microsoft.Tye.Core/ApplicationFactory.cs b/src/Microsoft.Tye.Core/ApplicationFactory.cs index 64c70008..37377495 100644 --- a/src/Microsoft.Tye.Core/ApplicationFactory.cs +++ b/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."); diff --git a/src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs b/src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs index 48487793..7cf764bd 100644 --- a/src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs +++ b/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 EnvironmentVariables { get; } = new List(); } } diff --git a/src/tye/ApplicationBuilderExtensions.cs b/src/tye/ApplicationBuilderExtensions.cs index c5099c2c..34256471 100644 --- a/src/tye/ApplicationBuilderExtensions.cs +++ b/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 {