azure - C# 如何从 Azure 应用服务 RDP 连接到本地 Windows 服务器?
问题描述
我有一个托管在 azure app 服务中的 Asp.net 核心 web api。我的 web api 应该连接到一个或多个 On Premise Windows 服务器以创建 DNS 记录。Windows 服务器正在运行 DNS 服务。我正在使用 System.Management 连接到本地 Windows 服务器。
但是,我没有成功从 azure app 服务连接到远程服务器。我确信我缺少某种配置,但我不知道..
这是我的代码:
using System.Management;
public static ManagementScope ConnectDNSServer(string dnsServerName, PCSCredential useMyInfo)
{
ConnectionOptions options = new ConnectionOptions
{
Username = useMyInfo.WindowsDomain + "\\" + useMyInfo.UserName,
Password = useMyInfo.PassString
};
try
{
ManagementScope scope = new ManagementScope(@"\\" + dnsServerName + "\\root\\MicrosoftDNS", options);
scope.Connect();
return scope;
}
catch
{
//ManagementScope scopeEx = new ManagementScope();
}
return null;
}
我收到此错误:
System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
解决方案
在 Azure 应用服务上 - 无论地址如何,应用程序都无法使用端口 445、137、138 和 139 连接到任何地方。换句话说,即使连接到非私有 IP 地址或虚拟网络地址,也无法连接到端口不允许使用 445、137、138 和 139。
附加信息,标准/本机 Azure Web 应用在称为沙盒的安全环境中运行。每个应用程序都在自己的沙箱内运行,将其执行与同一台机器上的其他实例隔离开来,并提供额外的安全性和隐私性,否则这些应用程序将无法使用。所以,这似乎是由于沙盒。
在这种环境下,通过 Internet 访问应用程序的唯一方法是通过已经暴露的 HTTP (80) 和 HTTPS (443) TCP 端口;应用程序可能不会在其他端口上侦听来自 Internet 的数据包。与本地地址(例如 localhost、127.0.0.1)和机器自身 IP 的连接尝试将失败,除非同一沙箱中的另一个进程在目标端口上创建了侦听套接字: https ://github.com/projectkudu/kudu /wiki/Azure-Web-App-sandbox#network-endpoint-listening
推荐阅读
- html - 两个文本对齐。一张图片
- integration - 如何在 Visual Studio ssdt 中修复“在输入列集合中找不到指定的输入列”
- docker - 如何使用 jenkins x 在 kubernetes 上部署 docker 镜像
- python - 将 Pandas 数据绘制为条形图数组不符合 sharex = True
- python - 如何在不添加报价的情况下附加列表
- php - adobe echosine :create webhook from api 给出了 INVALID_API_ACCESS_POINT 的响应
- javascript - JS:如何从base64创建图像类型的文件
- java - 我正在获取 MySQL 服务器版本,以便在“.null”附近使用正确的语法
- android - 由于缺少 JAR 签名,Android Studio 不允许我上传 APK
- ember.js - 尝试将 Ember 2.14.2 更新到 Ember 2.18.2 时出错