Search code examples
azurevirtual-machineazure-worker-rolesworkerazure-virtual-machine

Deploy Worker Role To Azure VM


I have a Worker Role that need complex environment settings (install a couple of softwares, setup some directories and etc) so I want to deploy it to VM ( instead of Cloud Service that specialize in more simple environment without pre configure settings).

The problem that I can only publish to Cloud Service (from VS 2013), am I missing something ?

I tried to find some article and relevant materiel about deploy a Worker Role to a VM and the only things I found is related to the Cloud Service.

How can I do it ? (or provide me a general guidelines)


Solution

  • Simply put, you can't deploy a Worker Role as is into an Azure Virtual Machine (IaaS) without doing code changes.

    Things you could do:

    • Isolate your business logic into a separate DLL and then create a separate Windows Service project which consumes this DLL. Then you could deploy that Windows Service into a VM. Do note that your business logic DLL should not have references to any libraries which will only run in Cloud Services kind of environment (e.g. Diagnostics, ServiceRuntime etc.)
    • Do take a look at Startup Tasks for Cloud Services. They do provide a mechanism to perform additional tasks like installing software when your Cloud Service is deployed.