I have an ASP.Net application that tries to execute the ‘az login’ command on Azure using power shell commands. Below is the code that I am using:
PowerShell powershell = PowerShell.Create();
using (Runspace runspace = RunspaceFactory.CreateRunspace())
powershell.Runspace = runspace;
PSCommand PScmd = new PSCommand();
string cmdStr = “az login -u ‘firstname.lastname@example.org’ -p ‘*******’”;
var results = powershell.Invoke();
When this code is executed locally, it runs successfully, but when I deploy the same code on Azure app service and browsethe service, I get an error message saying ‘az is not recognized as the name of a cmdlet’. I even went to the ‘Kudu’ powershell where the code is deployed and tried to run the same command there but still got the same error. Please suggest what needs to be done in this case.