繁体   English   中英

为什么使用从点网代码运行的Power Shell命令执行时,z登录命令在Azure上不起作用?

[英]Why az login command does not work on Azure when executed with power shell command that runs from dot net code?

我有一个ASP.Net Web应用程序,该应用程序尝试使用Power Shell命令登录到Azure。 以下代码正用于此目的:

        Runspace runspace = RunspaceFactory.CreateRunspace();
        runspace.Open();
        Pipeline pipeline = runspace.CreatePipeline();
        pipeline.Commands.AddScript("az login -u 'vtripathi@hsdyn.com' -p '********'");
        pipeline.Commands.Add("Out-String");
        var output = pipeline.Invoke();
        string result = output[0].ToString();

这里的问题是,当我在系统上本地运行此应用程序时,它可以成功登录到Azure,但是当我在Azure应用程序服务上部署相同的应用程序时,出现以下错误:

Server Error in '/' Application.    
The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 

请提出可能出问题的地方。

Az Login是来自Azure CLI的命令,因此要运行此命令,需要在运行CLI的计算机上安装CLI。 CLI将不会安装在Azure Web应用程序上。

如果您编写的是.net Web应用程序,则您确实希望使用.net Azure API直接与Azure REST API通信,而不是尝试使用CLI。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM