0
votes

I am trying to develop an azure cloud service . I have two vm in azure one has an sql server where i have my database and other VM is running a web and worker role. I am using MVC and accessing the database through web role. Now i want to pass this same datacontext from web role to worker role to do some background tasks in it. When i pass this datacontext it says that it is unavailable in worker role. Can someone please help me to address my solution ? Or is there any best practice that i can use to get this done ?

1
Since you're on Azure, you could easily use its Service Bus to exchange data between the roles (azure.microsoft.com/en-gb/services/service-bus).Strillo

1 Answers

0
votes

I think you have things mixed up a bit, regarding web role and worker role. Those don't exist side-by-side in the same VM. They are each a definition of a type of VM (the web role being Windows Server with IIS, worker role without IIS). When you spin up instances of a web or worker role, those are independent VMs.

So... there's no way to really pass a data context object across role instances, unless you have a method for accomplishing this across actual machines (virtual machines in this case, but same challenge).