简体   繁体   English

Azure 应用服务内的远程连接

[英]Remote connections inside Azure App Service

I am trying to open a connection inside my C# MVC.NET application, to retrieve some data and show them on a view.我试图在我的 C# MVC.NET 应用程序中打开一个连接,以检索一些数据并将它们显示在视图上。 Everything works good when developing on localhost, using Visual Studio Community 2015 and its integrated IIS Express server.使用 Visual Studio Community 2015 及其集成的 IIS Express 服务器在本地主机上进行开发时,一切正常。

When I deploy my application onto an Azure App Service, network connections stop working, I noticed my application becomes unable to reach outside network directly (ie I cannot use SSH.NET to give a command to a server or retrieve data).当我将应用程序部署到 Azure 应用服务时,网络连接停止工作,我注意到我的应用程序无法直接访问外部网络(即我无法使用 SSH.NET 向服务器发出命令或检索数据)。 Application is still working (views are rendered/other controller actions execute perfectly) but when I request a network connection anywhere inside the app, failure happens.应用程序仍在工作(视图呈现/其他控制器操作完美执行)但是当我在应用程序内的任何地方请求网络连接时,就会发生故障。

Also, opening App Service console in Azure dashboard, I've noticed that I'm even unable to ping any host due to a missing IP driver.此外,在 Azure 仪表板中打开应用服务控制台时,我注意到由于缺少 IP 驱动程序,我什至无法 ping 任何主机。

What are the missing steps in my deployment or what am I misunderstanding?我的部署中缺少哪些步骤或我误解了什么?

If you are trying to connect to a VM or a on prem resource you need to set up Virtual Network to do this.如果您尝试连接到 VM 或本地资源,则需要设置虚拟网络来执行此操作。 As explained here .正如这里所解释的。 You can not directly make connection to resource directly outside the network.您不能直接连接到网络外的资源。

I know I am late in the party but here is my two cent.我知道我迟到了,但这是我的两分钱。

You should check that if the application pool user of your app service have access rights of the network/machine you are trying to connect because when you execute in the dev environment it works because I think the user on IIS would have rights to access the test network/machine.您应该检查您的应用服务的应用程序池用户是否具有您尝试连接的网络/机器的访问权限,因为当您在开发环境中执行时,它可以工作,因为我认为 IIS 上的用户有权访问测试网络/机器。

PS To achieve the same you can create a parameterised console application and trigger it using a hosted simple API on the remote machine. PS 为了达到同样的目的,您可以创建一个参数化的控制台应用程序并使用远程机器上托管的简单 API 来触发它。

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

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