Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Inversion Of Control(IoC) with Azure Worker Role

I'm working in Windows Azure and have created a worker role. The application works fine; many places in the application I'm referencing Azure specific classes, such as CloudBlobContainer to save files to Azure storage. I would like to run this application in a windows service or other hosting environment with no dependencies on Azure. The classes I have created have dependencies on Azure resources, when I change the application to run in non-Azure environment, I do not want to change a lot of code.

I have use Enterprise Library Unity and Ninject as an IoC container with ASP.NET MVC and they both worked great. But I'm having problems figuring out how to use Unity with an Azure Worker Role.

I've searched the web high and low, but have not been able to find many resources to help me with my issue. Does anyone know where I can get more information on using Unity with an Azure Worker Role?

Below are a few articles I've found, but still do not provide me enough information to go forward:
Abstracting Away Azure: How to Run Outside of the Cloud

IOC for RoleEntryPoint

like image 558
Mike Barlow - BarDev Avatar asked Mar 14 '11 03:03

Mike Barlow - BarDev


1 Answers

We used Unity in the Workers of our sample. Take a look here: http://msdn.microsoft.com/en-us/library/ff966499.aspx

in fact these samples abstract common patterns found with workers such as:

  • Get a message from a queue
  • Do somtheing
  • Delete message from queue

etc.

like image 149
Eugenio Pace Avatar answered Sep 20 '22 10:09

Eugenio Pace