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
.NET Test invoking an Azure Function: An error occurred trying to start process 'func' with working directory. The system cannot find the file specified. #511
Comments
Tried
Tried
Then tried this
|
Started a GitHub community discussion: https://github.com/orgs/community/discussions/109546 |
Hello @jaliyaudagedara, Thank you for creating this issue and we will look into it :) |
I was able to get around the issue by doing the following in test code,
And the Still curious, why directly supplying the command doesn't work in GitHub workflows, but it works in Azure DevOps pipelines. |
Hello @jaliyaudagedara, Thank you once again for creating the issue. Upon investigating further, When you install a tool in a command-line environment, like the Azure Functions Core Tools using npm install -g, the tool's executable files are usually added to a directory on your system. For your command-line environment to find these executables when you type a command, the directory containing the executables needs to be included in an environment variable called PATH. The PATH variable is a list of directories that your command-line environment checks when you enter a command. Now, the way this PATH variable is handled can differ between environments: GitHub Actions: When you install a tool in one step of a GitHub Actions workflow (like npm install -g azure-functions-core-tools@4), the tool's executables are not automatically added to the PATH for the subsequent steps. This means, in a later step when your .NET code tries to start a new process with the func command, it can't find the func executable and throws an error. Azure DevOps Pipelines: In contrast, it appears that Azure DevOps Pipelines automatically add the directory of the installed tool to the PATH. So, when you install the Azure Functions Core Tools, the func command is immediately available for subsequent tasks in the pipeline. This is why changing your .NET code to start a powershell.exe process (which is always available in the PATH) and passing the func command as an argument works in GitHub Actions. The powershell.exe process can find and run the func command because it's executing it within its own environment where the PATH has been set correctly. I hope this helps clarify the difference. The handling of the PATH environment variable is a low-level detail of these CI/CD environments and is usually abstracted away from users, but it can cause issues like the one you're seeing. Please feel free to reach us if any further clarification required. Thanks!!! |
Thank you very much for the detailed explanation. That explains everything. Thanks again, very much appreciated! Closing the issue as it's the expected behavior per the design. |
Description: (I am not sure whether this is the correct repo to log this issue, but I couldn't find a more suitable repo. If you think this doesn't belong here, appreciate it if you could point me to a more suitable repo.)
I have a .NET Test project, and inside the Test project, I am invoking an Azure Function as follows.
I have installed
Azure Functions Core Tools
in the workflow before running thedotnet test
step. From the workflow when I dodotnet test
, which executes the above code, it fails with the following error.From the workflow, when I add a step to execute
func
, it's getting executed. So technically it's installed in the host (runner) where the workflow is running.But it's failing to execute from the application code.
My workflow looks like below:
Task version:
N/A
Platform:
Runner type:
Repro steps:
Repo: jaliyaudagedara/azure-functions-integration-tests
Expected behavior:
I have the same concept working on Azure DevOps pipelines on
windows-latest
, can't understand why the application code can't pick up globally installedazure-functions-core-tools
in GitHub workflows.The text was updated successfully, but these errors were encountered: