简体   繁体   English

如何从Azure VM内部访问数据?

[英]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.

相关问题 如何将特定的App_Data文件发布到Azure VM(IIS) - How to publish specific App_Data files to an Azure VM (IIS) 从 Azure 应用服务到 Azure VM 上托管的 API 的 API 调用--错误尝试以访问权限禁止的方式访问套接字 - API call from Azure App Service to API hosted on Azure VM --Error An attempt was made to access a socket in a way forbidden by its access permissions Azure DevOps连接VM和访问资源(应用程序) - Azure DevOps to connect VM and Access Resources (Application) 如何从 ASP.NET 应用程序内部访问 `Build.BuildNumber` Azure 变量? - How can I access the `Build.BuildNumber` Azure variable from the inside of an ASP.NET application? 无法从Azure Data Lake Analytics访问Azure Key Vault - Cannot access Azure Key Vault from Azure Data Lake Analytics 如何在我的Web Form应用程序中的任何地方访问来自Azure的用户数据? - How to access user data coming from Azure from everywhere in my Web Form App? 通过捕获的图像以编程方式创建Azure VM - Programatically creating an Azure VM from a captured image 从vm创建azure worker规则 - creating azure worker rules from a vm 从Windows Azure VM获取代码 - Getting code from Windows Azure VM 从vm azure c#分离磁盘 - detach disk from vm azure c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM