How to save one role implementing a client/server pattern in Azure?

Posted by Alfredo Delsors on Geeks with Blogs See other posts from Geeks with Blogs or by Alfredo Delsors
Published on Fri, 18 Feb 2011 19:11:47 GMT Indexed on 2011/02/18 23:26 UTC
Read the original article Hit count: 268

Filed under:

Sometimes you need to have an instance performing a server role when other instances are playing the client role. An example can be a file sharing like in this great post: http://blogs.msdn.com/b/mariok/archive/2011/02/11/sharing-folders-in-azure.aspx, one instance shares a folder that all other instances are using to write files that the server processes.

The problem is that there is not discovering mechanism in Azure that allows one instance to know where the instance acting as a server is located. A first approach can be having a server role and a client role like in the previous post. This means more instances, more money.

A solution to save this "server" role is to use Instance 0, always available, to act as a server. An instance can know that it should act as the server checking RoleEnvironment.CurrentRoleInstance.Id.EndsWith(".0"). Other instances can iterate the RoleEnvironment Instances collection to find the instance whose name ends with ".0", getting its endpoints and acting as its clients.

© Geeks with Blogs or respective owner