3

I want a web role for my site however I also want that site to communicate with another standalone application I have developed.

I see no need to have two VM's - can I have my worker role on the same VM as my wrb role?

Whats to stop me RDP'ing in the uploading my application there?

This role in particular requires connections on a high port number - do I have to change anything to allow this? (aparf from Windows Firewall on the VM)

(So far Azure has made my life far more complicated than justing paying for a hosted server)

David Makogon
  • 64,809
  • 21
  • 130
  • 175
markmnl
  • 10,001
  • 7
  • 64
  • 102

2 Answers2

4

I'll point you to other SO answers I've given on this, but... a Web Role and Worker Role are just Windows 2008 Servers, with and without IIS running. You can run everything in a Web Role if you want, and just scale the number of instances to handle the load. Or... create a Worker Role for some tasks that you don't want competing with your Web Role CPU/Memory/Network.

You can listen on any port, via tcp, http, or https. You may have up to 25 such ports open, and direct traffic to whichever role you want (and it'll be load-balanced across all instances of that role).

You do not want to RDP and install software. The VMs will not retain such changes upon reboot. This is the cool part of Windows Azure: Within your webrole.cs or workerrole.cs, you can set up whatever you want, then in Run(), simply sleep or kick off background tasks (or whatever). If, during boot, you need something installed (maybe an MSI or registry addition) that requires elevated privileges), you can use a startup task to do pretty much whatever you want. These changes are reapplied during reboot. Although... you can short-circuit this and skip installation if you find stuff is already installed (that is, sometimes your stuff will be preserved between reboots - you can't count on this, but you can certainly drop yourself a breadcrumb to know things have been installed...).

More SO answers for you, that I posted:

Community
  • 1
  • 1
David Makogon
  • 64,809
  • 21
  • 130
  • 175
  • just to be clear you say: I "can listen on any port, via tcp, http, or https", can I listen on my own TCP application level protocols? (You say TCP so I guess so, but you also say HTTP which suggests it may be limited to specfic well known application level protocols). – markmnl May 20 '12 at 02:25
  • As long as it's tcp, http, or https, you can fire up any listener you want, whether it's a .net ServiceHost, a Java web server such as Tomcat or Jetty, or whatever else you had in mind. UDP is not supported. – David Makogon May 20 '12 at 02:26
  • if it supports tcp then it has to support http and https - they are tcp - again I am unclear you give examples of ServiceHost and Java web server tech - it is my own TCP protocol nothing to do with existing web protocols - mine uses TCP berkely sockets - will that work? – markmnl May 20 '12 at 02:35
  • 1
    Sorry for not being clear. If you can write an exe that opens and listens on a port, you should be fine (as long as it's not udp-based). Remember that a Web or Worker Role is Windows 2008 Server with some add'l scaffold code. So... you'd run your app as you would on Windows Server. You'd just need to launch the app from the scaffold code (most likely from `OnStart()`). – David Makogon May 20 '12 at 03:53
1

Yes, you can convert Worker Roles into Windows Services and then deploy them with your Web Role.

A WebRole can define a RoleEntryPoint as well, so you use it to install and shutdown Windows Services upon startup. The rest, such as opening ports through Firewall, making changes to IIS and etc is better be written as command line script or .NET code and executed on the instance startup. This way you can scale your service by increasing number of instances easily.

Andrew Barber
  • 37,547
  • 20
  • 91
  • 118
Anton
  • 326
  • 1
  • 7