我正在尝试从我的c#app调用Azure Powershell命令(使用windows auth运行) Azure PowerShell sdk安装在Windows 2012 R2的“User1”框中,后者也是网络和框的管理员。 使用的代码:
string psFile= @"C:\AVC\Vmstatus.ps1 -VmName testvm";
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(psFile);
pipeline.InvokeAsync();
WaitHandle[] handles = new WaitHandle[2];
handles[0] = pipeline.Output.WaitHandle;
handles[1] = pipeline.Error.WaitHandle;
while (pipeline.PipelineStateInfo.State == PipelineState.Running)
{
switch (WaitHandle.WaitAny(handles))
{
case 0: a = pipeline.Output.Read();
vm.ip = ((dynamic)a).IpAddress;
vm.vmStatus = ((dynamic)a).PowerState;
vm.vmName = ((dynamic)a).name;
break;
case 1: object b = pipeline.Error.Read();
throw new CryptographicException(b.ToString());
}
}
场景的
我正在使用VS来调试IIS应用程序,并且收到的异常是
System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
FullyQualifiedErrorId = "Microsoft.WindowsAzure.Commands.Profile.ImportAzurePublishSettingsCommand"
深入研究问题: 1)为user1和user 2安装证书