C# How to RDP Connect to On Premise Windows Server from Azure App Services?

0

I have an Asp.net core web api hosted in azure app service. My web api should connect to one or many On Premise windows servers to create DNS records. The windows servers are running the DNS service. I am using System.Management to connect to the on premise windows servers.

However, I am not successful in connecting to the remote server from azure app service. I sure believe i am missing some kind of a configuration but I don't know..

Here is my code:

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;
}

I get this error:

System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
azure
wmi
azure-web-app-service
remote-desktop
asked on Stack Overflow Nov 5, 2019 by blogs4t

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0