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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
12 additions and
0 deletions
-
src/Microsoft.Tye.Core/ApplicationFactory.cs
-
src/Microsoft.Tye.Core/AzureFunctionServiceBuilder.cs
-
src/tye/ApplicationBuilderExtensions.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."); |
|
|
|
|
|
|
|
@ -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>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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 |
|
|
|
{ |
|
|
|
|