Is there a way to turn an existing class library into a worker role?
I don't want to add more projects to the solution especially when this project will only call MyLibrary.Class.Run()
.
Asked
Active
Viewed 1,817 times
7

Uri Abramson
- 6,005
- 6
- 40
- 62
-
Assuming this is supposed to be tagged `C#`, not `C`? – Jonathon Reinhart Aug 28 '13 at 08:40
-
@JonathonReinhart: He uses "class library" and C# style call, so it's surely C#. – sharptooth Aug 28 '13 at 08:43
-
I mean, it could be VB.net lol – Jonathon Reinhart Aug 28 '13 at 08:45
2 Answers
19
Eventually, I found the solution:
Add a cloud service project to the solution
I had to edit the project file of my class library and add this:
<RoleType>Worker</RoleType>
to the first<PropertyGroup>
element.In addition to that, my service entry point class had to extend
RoleEntryPoint
.Once this is done, right click no the Roles folder in the cloud service project and choose Add -> Worker role project in solution and choose my Class Library.
That's it.

Uri Abramson
- 6,005
- 6
- 40
- 62
-
-
1Because if you don't, when you do step 4 the VS GUI won't recognize your project as an eligible cloud service project. – Dennisch Oct 10 '14 at 11:52
-
1
-
This is very helpful for those wanting to use Topshelf.Azure. Thanks! – Dave Van den Eynde Dec 01 '15 at 07:35
1
You'll have to add a "cloud service" project (.ccproj) anyway. Then you can include a RoleEntryPoint
descendant to the project which you select as worker role payload (you do that when you add a new role to the cloud service project) and it should work.

sharptooth
- 167,383
- 100
- 513
- 979
-
1The Role Entry point is not enough... I finally got it to work. See my own answer. – Uri Abramson Aug 28 '13 at 08:56