[英]How to access data from inside an Azure VM?
Let's say I have a VM (windows) running on MS-Azure. 假设我有一个在MS-Azure上运行的VM(Windows)。 Lets say I have programs Y and Z on that VM which are logging some critical data.
可以说我在该VM上有程序Y和Z,它们正在记录一些关键数据。 Let's say I also have a program X inside the VM which accepts some arguments and returns some of that critical data based on filters.
假设我在VM内也有一个程序X,它接受一些参数并根据过滤器返回一些关键数据。
Now, I am building a front end webapp, An ASP.NET website, where the owner of the above mentioned VM can login and view data that program X can provide. 现在,我正在构建一个前端Webapp,即ASP.NET网站,上述VM的所有者可以在其中登录和查看程序X可以提供的数据。
I already have my logging programs running inside the VM and program X installed. 我已经在VM内运行了我的日志记录程序,并安装了程序X。 How can I access an exectuble inside a VM, pass arguments to it, run it and get results back to me?
如何访问VM中的exectuble,向其传递参数,运行它并将结果返回给我? is this doable?
这可行吗? Can someone suggest how I can achieve this?
有人可以建议我如何实现这一目标吗?
Thanks. 谢谢。
If your program X doesn't involve GUI, you may try to run it on the PS Remote Session. 如果程序X不涉及GUI,则可以尝试在PS Remote Session上运行它。 Here is a good guide about how to configure the powershell remote.
这是有关如何配置Powershell遥控器的良好指南 。
Also, here is the article about the port need opening on the firewall. 另外,这是有关需要在防火墙上打开端口的文章 。
By default PowerShell will use the following ports for communication (They are the same ports as WinRM)
默认情况下,PowerShell将使用以下端口进行通信(它们与WinRM是相同的端口)
TCP/5985 = HTTP
TCP / 5985 = HTTP
TCP/5986 = HTTPS
TCP / 5986 = HTTPS
If it involves GUI, as far as I know, the only solution is remoting to the VM with RDP. 据我所知,如果涉及GUI,则唯一的解决方案是使用RDP迁移到VM。
Besides, it is not a good idea to expose the WinRM or RDP ports on the internet. 此外,在Internet上公开WinRM或RDP端口不是一个好主意。 I would suggest you to create a VPN on Azure and use WinRM or RDP over VPN.
我建议您在Azure上创建VPN,并在VPN上使用WinRM或RDP。
You can run another executable using the System.Diagnostic.Process
class: 您可以使用
System.Diagnostic.Process
类运行另一个可执行文件:
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "X.exe";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Copied from: run console application in C# with parameters 复制自: 使用参数在C#中运行控制台应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.