Version
4.6.0+ab90faafcab539d63cd3d0ce5faf1bca4395fccc (64-bit)
Function Runtime Version: 4.1045.200.25556
Description
Azure Functions Core Tools fails to start the PowerShell worker when using PowerShell 7.4, which is documented as the GA/recommended version. The worker crashes immediately with a FileNotFoundException for Microsoft.Management.Infrastructure assembly, preventing local debugging entirely.
The error occurs during PowerShell worker initialization before any user code runs. Microsoft documentation states PowerShell 7.4 is GA and 7.2 ended support on November 8, 2024, but Core Tools 4.6.0 cannot initialize a PowerShell 7.4 session.
Error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(Assembly assembly, String name)
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
at Microsoft.Azure.Functions.PowerShellWorker.Utility.Utils.NewPwshInstance()
at Microsoft.Azure.Functions.PowerShellWorker.Worker.Main(String[] args)
Additional context:
- PowerShell 7.4 runs fine outside Functions (pwsh -Version shows 7.4.6)
- Microsoft.Management.Infrastructure.dll exists in PowerShell 7.4 installation: C:\Program Files\PowerShell\7\microsoft.management.infrastructure.dll
- The assemblies exist in Core Tools worker directory runtimes subdirectories:
- C:\Program Files\Microsoft\Azure Functions Core Tools\workers\powershell\7\runtimes\win10-x64\lib\netstandard1.6\Microsoft.Management.Infrastructure.dll
- C:\Program Files\Microsoft\Azure Functions Core Tools\workers\powershell\7\runtimes\win\lib\netcoreapp3.1\Microsoft.Management.Infrastructure.CimCmdlets.dll
- However, the PowerShell worker cannot locate/load these assemblies during initialization
- Core Tools Constants.cs sets PowerShellWorkerDefaultVersion = "7.4"
- Microsoft documentation states PowerShell 7.2 support ended November 8, 2024
- Using PowerShell 7.2 with FUNCTIONS_WORKER_RUNTIME_VERSION "7.2" works correctly (but is end-of-life)
This creates an impossible situation: Microsoft documentation recommends 7.4, but Core Tools 4.6.0 (the latest version) cannot run PowerShell 7.4 locally on Windows.
Steps to reproduce
-
Environment Setup:
- Install PowerShell 7.4.6 (only version installed, not 7.5)
- Install Azure Functions Core Tools 4.6.0
- Install .NET 8 runtime
- Windows 10/11 x64
-
Create PowerShell Function App:
func init --worker-runtime powershell
func new --template "Timer trigger" --name TimerTrigger1
-
Configure for PowerShell 7.4 in local.settings.json:
{
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "powershell",
"FUNCTIONS_WORKER_RUNTIME_VERSION": "7.4"
}
}
-
Start debugging:
func host start
Result: Worker crashes with Microsoft.Management.Infrastructure FileNotFoundException
Expected: Worker starts successfully as PowerShell 7.4 is documented as GA/supported
Update
- When I talked to a colleague about it, I asked if he could try it out using the steps to reproduce. In his case, he got it working without errors. So it appears to be some issue locally on my machine. I would still very much would like to know if there's anything I can do to fix this.
- We need to use PowerShell 7.4 as 7.2 is out of support, and we don't want to commit this version into source control. As a workaround, I created an environment variable on my machine where I set the FUNCTIONS_WORKER_RUNTIME_VERSION value to 7.2 and then it also works on my machine.
Version
4.6.0+ab90faafcab539d63cd3d0ce5faf1bca4395fccc (64-bit)
Function Runtime Version: 4.1045.200.25556
Description
Azure Functions Core Tools fails to start the PowerShell worker when using PowerShell 7.4, which is documented as the GA/recommended version. The worker crashes immediately with a FileNotFoundException for Microsoft.Management.Infrastructure assembly, preventing local debugging entirely.
The error occurs during PowerShell worker initialization before any user code runs. Microsoft documentation states PowerShell 7.4 is GA and 7.2 ended support on November 8, 2024, but Core Tools 4.6.0 cannot initialize a PowerShell 7.4 session.
Error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(Assembly assembly, String name)
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
at Microsoft.Azure.Functions.PowerShellWorker.Utility.Utils.NewPwshInstance()
at Microsoft.Azure.Functions.PowerShellWorker.Worker.Main(String[] args)
Additional context:
This creates an impossible situation: Microsoft documentation recommends 7.4, but Core Tools 4.6.0 (the latest version) cannot run PowerShell 7.4 locally on Windows.
Steps to reproduce
Environment Setup:
Create PowerShell Function App:
func init --worker-runtime powershell
func new --template "Timer trigger" --name TimerTrigger1
Configure for PowerShell 7.4 in local.settings.json:
{
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "powershell",
"FUNCTIONS_WORKER_RUNTIME_VERSION": "7.4"
}
}
Start debugging:
func host start
Result: Worker crashes with Microsoft.Management.Infrastructure FileNotFoundException
Expected: Worker starts successfully as PowerShell 7.4 is documented as GA/supported
Update