I have created an ASP.Net Web application. From this application, I am trying to execute power shell commands to log in to Azure. The command being used is 'az login'. When I run the application, I get proper response that is expected from a login command, the response tells me that the login is successful. The problem though, is that when I host the same application in IIS, I don't get the expected result, instead I get an empty response which indicates that there is some problem. Below is the code that I am using:
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript("az login -u [email protected] -p ********");
pipeline.Commands.Add("Out-String");
var output = pipeline.Invoke();
string result = output[0].ToString();
Please suggest what might be wrong.
It has to do with the application pool identity.
Change application pool identity to your account instead of default and it should work.