Jacques Mignault from 2020 Technologies has been prototyping a solution deployed on Windows Azure. One key technology they make use of today is .Net Remoting. During his prototyping efforts he hit ran into a few configuration steps that needed to be properly configured in order to get everything working properly. Below is his write-up on how he managed to get a .Net remoting endpoint exposed via a Worker Role service in Azure. Thanks for sharing with everyone Jacques!
Thanks,Jamie WakeamISV Software Architect AdvisorMicrosoft Canada
At 20-20 Technologies, we have a Service that runs on a Windows Server. The software, to make a long story short, uses catalogs to design kitchen and office interior layouts. The service simply exposes classes using .NET Remoting and software clients work with these classes.
My goal was to expose these classes using .NET Remoting from Windows Azure.
First I created a worker role in Azure and I assigned a TCP endpoint to the project in the configuration page.
Then in the worker role's Run method, I create an instance of a class which does the job of registering a channel for Remoting.
public class WorkerRole : RoleEntryPoint { public RemotingServer RS = null;
public override void Run() { RS = new RemotingServer(); Trace.WriteLine("WorkerRole1 entry point called", "Information"); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } } ...
The actual Remoting configuration is done in the RemotingServer class:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Tcp;using Microsoft.WindowsAzure.ServiceRuntime;namespace WorkerRole1{ public class RemotingServer { public RemotingServer() { TcpServerChannel channel = new TcpServerChannel(RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["API2020Managed"].IPEndpoint.Port); ChannelServices.RegisterChannel(channel, false); WellKnownServiceTypeEntry servicetype = new WellKnownServiceTypeEntry(typeof(API2020Managed,"API2020Managed",WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(servicetype); API2020Managed API = new API2020Managed(); RemotingServices.Marshal((API), "API2020Managed"); } }}
The magic trick is passing the port from the instance endpoint. Microsoft documentation states that the worker role's internal endpoint port number is different than the port number which is exposed on the outside.
Thus the client code below will actually find the server's class from either your local machine or from another Azure application.
API2020Interfacex myobject = (API2020Interfacex)Activator.GetObject(typeof(API2020Interfacex), "tcp://" + url.Text + ":3029/API2020Managed");
Note that API2020Interfacex is an interface class which is used to define the API2020Managed class.
So that's the trick for using .NET Remoting in Azure.
Jacques Mignault20-20 Technologies Inc.Laval, Quebec.