-
Notifications
You must be signed in to change notification settings - Fork 457
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
base: main
Are you sure you want to change the base?
Conversation
with accompanying test Fixes Azure#2465
test/Azure.Functions.Cli.Tests/ActionsTests/StartHostActionTests.cs
Outdated
Show resolved
Hide resolved
…tools into brandonh/fix/2465 # Conflicts: # release_notes.md # test/Cli/Func.UnitTests/ActionsTests/StartHostActionTests.cs
adf6ec8
to
78bd207
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
GlobalCoreToolsSettings.Init(secretsManager.Object, []); | ||
|
||
var startHostAction = new StartHostAction(secretsManager.Object, processManager.Object) |
There was a problem hiding this comment.
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:
azure-functions-core-tools/test/Cli/Func.E2ETests/Commands/FuncStart/MissingConfigTests.cs
Lines 50 to 83 in e963a76
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
with accompanying test
Fixes #2465
Issue describing the changes in this PR
resolves #2465
Pull request checklist
release_notes.md