Not sure if this is possible in Azure services and if it is whats the best approach.
I have a class which is extracting data from my database and building an xml output. Under normal circumstances since this is running in a worker role, it will run when necessary and push the XML to an external web service. However I also need the ability to expose that functionality as a service so that a different external web service can make a web service call to my system and get that very same XML response. I can setup a RESTful webservice in a worker role and build the same functionality as exists in my worker role - the problem is that I now have duplicate code.
How can I set this up so that my code to extra data from the DB, perform some calculations, generate the xml all sits in one location that is accessible from both a webrole (triggered by external web service call) and worker role (on regular running schedule).
I have looked through all the questions regarding TCP internal endpoints and worker webrole communication but none of them seem to cover this case of allowing a webrole to call a method on the workerrole and pass that data on to the caller.
If someone can help me with this would be very much appreciated. Thanks