Skip to content

Conversation

apranaseth
Copy link
Member

@apranaseth apranaseth commented Sep 26, 2025

This is to enable worker indexing for Logic Apps workflow app kind behind an environment variable. The settings used by Logic Apps are "FUNCTIONS_INPROC_NET8_ENABLED": "1", "FUNCTIONS_WORKER_RUNTIME": "dotnet" and we are bringing up a "dotnet" worker.

resolves #11386

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

@Copilot Copilot AI review requested due to automatic review settings September 26, 2025 18:44
@apranaseth apranaseth requested a review from a team as a code owner September 26, 2025 18:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables worker indexing for Logic Apps when running in codeful mode behind an environment variable setting. The change allows Logic Apps to use the dotnet worker runtime with specific environment variables while maintaining backward compatibility with existing Logic Apps that don't use codeful mode.

  • Adds WORKFLOW_CODEFUL_ENABLED environment variable support to control codeful mode behavior
  • Modifies worker indexing logic to allow indexing for Logic Apps when codeful mode is enabled
  • Disables strict worker runtime validation for Logic Apps in codeful mode

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/WebJobs.Script/Environment/EnvironmentSettingNames.cs Adds new environment variable constant for Logic App codeful mode
src/WebJobs.Script/Environment/EnvironmentExtensions.cs Implements extension method to check if Logic App codeful mode is enabled
src/WebJobs.Script/Utility.cs Updates worker indexing logic to allow indexing for Logic Apps in codeful mode
src/WebJobs.Script/Host/ScriptHost.cs Disables worker runtime validation for Logic Apps in codeful mode

/// </summary>
public static bool IsLogicAppCodefulModeEnabled(this IEnvironment environment)
{
bool.TryParse(environment.GetEnvironmentVariable(LogicAppCodefulModeEnabled), out bool logicAppCodefulModeEnabled);
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Use the full qualified name EnvironmentSettingNames.LogicAppCodefulModeEnabled instead of the unqualified constant name to improve code clarity and follow C# best practices.

Copilot generated this review using guidance from repository custom instructions.

if (!cancellationToken.IsCancellationRequested)
{
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = true;
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = _environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled() ? false : true;
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The ternary operator ? false : true is unnecessarily verbose. This can be simplified to !(_environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled()) for better readability.

Suggested change
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = _environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled() ? false : true;
bool throwOnWorkerRuntimeAndPayloadMetadataMismatch = !(_environment.IsLogicApp() && _environment.IsLogicAppCodefulModeEnabled());

Copilot uses AI. Check for mistakes.

@surgupta-msft
Copy link
Contributor

surgupta-msft commented Sep 29, 2025

I have a few questions/comments related to this PR -

  • Do we need these changes in dev branch? My understanding is that Logic apps uses in-proc branch only. We may need for consistency purpose between dev and in-proc - but double checking this.
  • Could you please complete the PR checklist in the description and add to the release notes?
  • It would be helpful if you can create a github issue and provide context about the changes. I am not very clear about the ask and changes here. Please link github issue in the PR description.
  • Please add some tests too.

Let me know if you need help with any of these items, happy to assist.

@apranaseth
Copy link
Member Author

I have a few questions/comments related to this PR -

  • Do we need these changes in dev branch? My understanding is that Logic apps uses in-proc branch only. We may need for consistency purpose between dev and in-proc - but double checking this.
  • Could you please complete the PR checklist in the description and add to the release notes?
  • It would be helpful if you can create a github issue and provide context about the changes. I am not very clear about the ask and changes here. Please link github issue in the PR description.
  • Please add some tests too.

Let me know if you need help with any of these items, happy to assist.

Yeah we plan to use the out of proc model soon so wanted to keep these changes in sync. I have updated the checklist and added github issue and test.

/// </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.

// Machine identifier
public const string AntaresComputerName = "COMPUTERNAME";

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";

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.

string appName = environment.GetAzureWebsiteUniqueSlotName();

bool workerIndexingFeatureFlagSet = FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagEnableWorkerIndexing, environment);
bool workerIndexingDisabledViaHostingConfig = functionsHostingConfigOptions.WorkerIndexingDisabledApps.ToLowerInvariant().Split("|").Contains(appName);
Copy link
Contributor

Choose a reason for hiding this comment

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

For scenario, if (environment.IsLogicApp() && environment.IsLogicAppCodefulModeEnabled()), below line will be executed -

bool workerIndexingDisabledViaHostingConfig = functionsHostingConfigOptions.WorkerIndexingDisabledApps.ToLowerInvariant().Split("|").Contains(appName);

This line is for Functions apps for which indexing is disabled via hosting config. Let's say indexing is disabled for function app "app1" and there is a logic app with the same name, then indexing will be disabled for that LA too. But our requirement is to enable indexing for above scenario.

Fix -

bool workerIndexingDisabledViaHostingConfig = !environment.IsLogicApp() && functionsHostingConfigOptions.WorkerIndexingDisabledApps.ToLowerInvariant().Split("|").Contains(appName);

Add/update existing tests to cover this scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable worker indexing for workflow app
2 participants