Hi IIS experts. I've created a Blazor Server app that needs to execute azure powershell cmdlets through a c# class, see method below..
public void ConnectAzAccount()
{
InitialSessionState initialState = InitialSessionState.CreateDefault();
initialState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Bypass;
initialState.LanguageMode = PSLanguageMode.FullLanguage;
initialState.ImportPSModule(new string[] { "Az.Accounts" });
Runspace runspace = RunspaceFactory.CreateRunspace(initialState);
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
string sScriptCommand = "Connect-AzAccount";
pipeline.Commands.AddScript(sScriptCommand);
var outputCollection = pipeline.Invoke();
}
When i execute on my dev VM, using VS2019 & IIS express, the code above when executed will open an authentication page, which i select the azure account to login with and then I can run other cmdlets in my project without an issue.
However., when deploying the project to IIS (using folder based deployment, and setting IIS application pool (".Net CLR Version" = "No managed code") The login window never appears so cannot authenticate to azure powershell.
Any ideas would be greatly appreciated, i have even added the ApplicationPoolIdentity account to the server admin group incase this was permissions related.
Thanks
David