Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/WebJobs.Script/Environment/EnvironmentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ public static bool IsLogicApp(this IEnvironment environment)
return !string.IsNullOrEmpty(appKind) && appKind.Contains(ScriptConstants.WorkFlowAppKind);
}

/// <summary>
/// Gets if codeful mode is enabled for Logic App app kind.
/// </summary>
public static bool IsLogicAppCodefulModeEnabled(this IEnvironment environment)
{
bool.TryParse(environment.GetEnvironmentVariable(EnvironmentSettingNames.LogicAppCodefulModeEnabled), out bool logicAppCodefulModeEnabled);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which component will be setting this Environment variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be set by the Logic Apps customers in the app settings manually for now. But later we will make it first class.

return logicAppCodefulModeEnabled;
}

/// <summary>
/// Gets if runtime environment needs multi language.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion src/WebJobs.Script/Environment/EnvironmentSettingNames.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace Microsoft.Azure.WebJobs.Script
Expand Down Expand Up @@ -155,6 +155,8 @@ public static class EnvironmentSettingNames

public const string AppKind = "APP_KIND";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line 157 and add a comment for LA settings -

// Logic apps settings
public const string AppKind = "APP_KIND";
public const string LogicAppCodefulModeEnabled = "WORKFLOW_CODEFUL_ENABLED";


public const string LogicAppCodefulModeEnabled = "WORKFLOW_CODEFUL_ENABLED";

public const string DrainOnApplicationStopping = "FUNCTIONS_ENABLE_DRAIN_ON_APP_STOPPING";
}
}
4 changes: 2 additions & 2 deletions src/WebJobs.Script/Host/ScriptHost.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -803,7 +803,7 @@ internal async Task<Collection<FunctionDescriptor>> GetFunctionDescriptorsAsync(
Collection<FunctionDescriptor> functionDescriptors = new Collection<FunctionDescriptor>();
if (!cancellationToken.IsCancellationRequested)
{
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = true;
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = !(_environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear on why do we need to make changes here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Logic Apps is using dotnet as the runtime, if you look below this is set to true by default and we would throw an exception here which causes the host startup to fail.

// this dotnet isolated specific logic is temporary to ensure in-proc payload compatibility with "dotnet-isolated" as the FUNCTIONS_WORKER_RUNTIME value.
if (string.Equals(workerRuntime, RpcWorkerConstants.DotNetIsolatedLanguageWorkerName, StringComparison.OrdinalIgnoreCase) && !_environment.IsPlaceholderModeEnabled())
{
Expand Down
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,8 @@ public static void ValidateRetryOptions(RetryOptions
// WORKER_INDEXING_DISABLED contains the customers app name worker indexing is then disabled for that customer only
public static bool CanWorkerIndex(IEnumerable<RpcWorkerConfig> workerConfigs, IEnvironment environment, FunctionsHostingConfigOptions functionsHostingConfigOptions)
{
if (environment.IsLogicApp())
// NOTE(apseth): Enabling the worker indexing for Logic Apps with codeful mode enabled.
if (environment.IsLogicApp() && !environment.IsLogicAppCodefulModeEnabled())
{
return false;
}
Expand Down
25 changes: 25 additions & 0 deletions test/WebJobs.Script.Tests/UtilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,31 @@ private void VerifyCanWorkerIndexUtility(bool workerIndexingFeatureFlag, bool wo
Assert.Equal(expected, workerShouldIndex);
}

[Theory]
[InlineData(true, true, true)]
[InlineData(true, false, false)]
public void WorkerIndexingDecisionLogic_LogicApps(bool workerIndexingFeatureFlag, bool enableIndexingForCodeful, bool expected)
{
var testEnv = new TestEnvironment();
testEnv.SetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime, RpcWorkerConstants.DotNetExecutableName);
testEnv.SetEnvironmentVariable(EnvironmentSettingNames.AppKind, ScriptConstants.WorkFlowAppKind);

if (workerIndexingFeatureFlag)
{
testEnv.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagEnableWorkerIndexing);
}

if (enableIndexingForCodeful)
{
testEnv.SetEnvironmentVariable(EnvironmentSettingNames.LogicAppCodefulModeEnabled, "true");
}

RpcWorkerConfig workerConfig = new RpcWorkerConfig() { Description = TestHelpers.GetTestWorkerDescription("dotnet", "none", true) };

bool workerShouldIndex = Utility.CanWorkerIndex(new List<RpcWorkerConfig>() { workerConfig }, testEnv, new FunctionsHostingConfigOptions());
Assert.Equal(expected, workerShouldIndex);
}

[Theory]
[InlineData(true, false)]
[InlineData(false, false)]
Expand Down