Skip to content

Handling Functions Runtime Environment env var when set by user #4535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

brandonh-msft
Copy link
Member

with accompanying test
Fixes #2465

Issue describing the changes in this PR

resolves #2465

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_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
  • I have added all required tests (Unit tests, E2E tests)

@brandonh-msft brandonh-msft requested a review from a team as a code owner July 16, 2025 16:26
…tools into brandonh/fix/2465

# Conflicts:
#	release_notes.md
#	test/Cli/Func.UnitTests/ActionsTests/StartHostActionTests.cs
@liliankasem
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).


GlobalCoreToolsSettings.Init(secretsManager.Object, []);

var startHostAction = new StartHostAction(secretsManager.Object, processManager.Object)
Copy link
Member

Choose a reason for hiding this comment

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

My bad, I just noticed that you're actually running the CLI with this test. So it's not a unit test but would need to use the E2E test framework we have. Here is an example of how to write one of those instead:

public async Task Start_LanguageWorker_InvalidFunctionJson_FailsWithExpectedError()
{
var port = ProcessHelper.GetAvailablePort();
var functionName = "HttpTriggerJS";
var testName = nameof(Start_LanguageWorker_InvalidFunctionJson_FailsWithExpectedError);
// Initialize Node.js function app using retry helper
await FuncInitWithRetryAsync(testName, [".", "--worker-runtime", "node", "-m", "v3"]);
// Add HTTP trigger using retry helper
await FuncNewWithRetryAsync(testName, [".", "--template", "Httptrigger", "--name", functionName, "--language", "node"], workerRuntime: "node");
// Modify function.json to include an invalid binding type
var filePath = Path.Combine(WorkingDirectory, functionName, "function.json");
var functionJson = await File.ReadAllTextAsync(filePath);
functionJson = functionJson.Replace("\"type\": \"http\"", "\"type\": \"http2\"");
await File.WriteAllTextAsync(filePath, functionJson);
// Call func start
var funcStartCommand = new FuncStartCommand(FuncPath, testName, Log);
funcStartCommand.ProcessStartedHandler = async (process) =>
{
await ProcessHelper.ProcessStartedHandlerHelper(port, process, funcStartCommand.FileWriter ?? throw new ArgumentNullException(nameof(funcStartCommand.FileWriter)));
};
var result = funcStartCommand
.WithWorkingDirectory(WorkingDirectory)
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
.Execute(["--port", port.ToString(), "--verbose"]);
// Validate error message
result.Should().HaveStdOutContaining("The binding type(s) 'http2' were not found in the configured extension bundle. Please ensure the type is correct and the correct version of extension bundle is configured.");
}

I believe there is a doc too

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

Successfully merging this pull request may close these issues.

An item with the same key has already been added. Key: AZURE_FUNCTIONS_ENVIRONMENT
2 participants