I would like to run PowerShell commands in a V2 C# Azure Function App. I have tried to run PowerShell Core (which, as far as I know, is the only way I can access PS with .NET Core) from a .NET Core 2.1 Project in Visual Studio, which worked just fine, however, with a C# Azure Function App (which uses .NET Core) project I get the following error when I try to access the URL:
Executed 'Function1' (Failed, Id=dbb00673-938b-4d50-9576-9b3a4ec06c06) [2018-11-05 09:51:17] System.Private.CoreLib: Exception while executing function: Function1. AmberTest: Could not load file or assembly 'System.Management.Automation, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.
I have the following NuGet packages installed (for PowerShell Core):
- Microsoft.PowerShell.Commands.Diagnostics 1.0.23
- Microsoft.PowerShell.SDK 6.1.0
- Microsoft.WSMan.Management 6.1.0
I could use a V1 Function App with PowerShell and get the desired functionality, but I want to know whether and how is it possible to call PowerShell from a C# Azure Function App.