diff --git a/src/WebJobs.Script/Environment/EnvironmentExtensions.cs b/src/WebJobs.Script/Environment/EnvironmentExtensions.cs index fd1da3ef56..82359bc339 100644 --- a/src/WebJobs.Script/Environment/EnvironmentExtensions.cs +++ b/src/WebJobs.Script/Environment/EnvironmentExtensions.cs @@ -425,6 +425,15 @@ public static bool IsLogicApp(this IEnvironment environment) return !string.IsNullOrEmpty(appKind) && appKind.Contains(ScriptConstants.WorkFlowAppKind); } + /// + /// Gets if codeful mode is enabled for Logic App app kind. + /// + public static bool IsLogicAppCodefulModeEnabled(this IEnvironment environment) + { + bool.TryParse(environment.GetEnvironmentVariable(EnvironmentSettingNames.LogicAppCodefulModeEnabled), out bool logicAppCodefulModeEnabled); + return logicAppCodefulModeEnabled; + } + /// /// Gets if runtime environment needs multi language. /// diff --git a/src/WebJobs.Script/Environment/EnvironmentSettingNames.cs b/src/WebJobs.Script/Environment/EnvironmentSettingNames.cs index 777838abb2..1be7d0b532 100644 --- a/src/WebJobs.Script/Environment/EnvironmentSettingNames.cs +++ b/src/WebJobs.Script/Environment/EnvironmentSettingNames.cs @@ -150,6 +150,8 @@ public static class EnvironmentSettingNames public const string AppKind = "APP_KIND"; + public const string LogicAppCodefulModeEnabled = "WORKFLOW_CODEFUL_ENABLED"; + public const string DrainOnApplicationStopping = "FUNCTIONS_ENABLE_DRAIN_ON_APP_STOPPING"; } } diff --git a/src/WebJobs.Script/Host/ScriptHost.cs b/src/WebJobs.Script/Host/ScriptHost.cs index 3082c947ed..3f6a4ea97d 100644 --- a/src/WebJobs.Script/Host/ScriptHost.cs +++ b/src/WebJobs.Script/Host/ScriptHost.cs @@ -787,7 +787,7 @@ internal async Task> GetFunctionDescriptorsAsync( Collection functionDescriptors = new Collection(); if (!cancellationToken.IsCancellationRequested) { - bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = true; + bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = !(_environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled()); // 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)) { diff --git a/src/WebJobs.Script/Utility.cs b/src/WebJobs.Script/Utility.cs index 5bdaa86319..ac7d657b91 100644 --- a/src/WebJobs.Script/Utility.cs +++ b/src/WebJobs.Script/Utility.cs @@ -1028,7 +1028,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 workerConfigs, IEnvironment environment, FunctionsHostingConfigOptions functionsHostingConfigOptions) { - if (environment.IsLogicApp()) + // NOTE: Enabling the worker indexing for Logic Apps with codeful mode enabled. + if (environment.IsLogicApp() && !environment.IsLogicAppCodefulModeEnabled()) { return false; } diff --git a/test/WebJobs.Script.Tests/UtilityTests.cs b/test/WebJobs.Script.Tests/UtilityTests.cs index 46bc929fcc..8a483358ba 100644 --- a/test/WebJobs.Script.Tests/UtilityTests.cs +++ b/test/WebJobs.Script.Tests/UtilityTests.cs @@ -966,6 +966,31 @@ public void WorkerIndexingDecisionLogic_NullConfig(bool workerIndexingFeatureFla 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() { workerConfig }, testEnv, new FunctionsHostingConfigOptions()); + Assert.Equal(expected, workerShouldIndex); + } + [Theory] [InlineData(true, false)] [InlineData(false, false)]