I am trying to execute PowerShell scripts in azure functions but it just ignores it, doesn't throw any errors, and I know the lines are not being really executed because it's just instant, and when running from ConsoleApp (same lines of code) it takes like 5 to 10 seconds and then brings the information well.
I looked into it and what I found is that I have to MANUALLY insert dll files to the output of the build. The thing is that I tried that and didn't have luck either.
using (PowerShell ps = PowerShell.Create())
{
foreach (var line in query)
{
ps.AddScript(line);
ps.AddParameters(prms);
var pipelineObjects = await ps.InvokeAsync().ConfigureAwait(false);
foreach (var item in pipelineObjects)
{
if (item != null) { } // it's always null here
}
}
The line that should bring information is this one:
Get-AdminPowerAppEnvironment
It works on Console App well, but not in Azure Function.
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>