41

I've written a Windows Service in C# that does a whole bunch of background admin tasks on the database. Now my customer wants to migrate the whole shebang to Azure. I know next to nothing about Azure, and my customer says you can't run a Windows Service on Azure. I've googled for this topic and come out with a few very specific case studies of what somebody did to move their Windows Service to Azure, assuming a fairly high level of understanding of how Azure works, but no general articles about whether or not Windows Services can run under Azure, or what to do to adapt them.

I would really like to see a clear answer and explanation to the first question (can you run a Windows Service under Azure?), and if the answer is no, I'd love to find a step-by-step guide for converting a Windows Service to something Azure-compatible.

Thanks!

Shaul Behr
  • 36,951
  • 69
  • 249
  • 387

7 Answers7

24

Yes you can do that - for a simple walkthrough see http://blogs.msdn.com/b/mwasham/archive/2011/03/30/migrating-a-windows-service-to-windows-azure.aspx

Other links with relevant information:

Community
  • 1
  • 1
Yahia
  • 69,653
  • 9
  • 115
  • 144
  • 2
    Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Daniel A. White Mar 19 '16 at 00:27
6

You can run whatever you want, including a Windows Service.

I think you'd be happier converting to a WorkerRole, though, which should be very straightforward.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
user94559
  • 59,196
  • 6
  • 103
  • 103
  • Too bad you didn't add a refference for a short tutorial or an article like this one: http://blogs.msdn.com/b/joseph_fultz/archive/2010/04/02/migrating-windows-service-to-azure-worker-role-image-conversion-example-using-storage.aspx – Uri Abramson Aug 21 '13 at 17:05
  • 1
    What a weird comment. The accepted answer has several links (more recent than the one you suggest). – user94559 Aug 21 '13 at 17:23
  • 4
    Actually, i don't mean to be a pr**k but the accepted answer is talking about "hosting" a windows service inside a Worker Role while you suggest to "convert" the windows service into a worker role - those two are different approaches and i gotta say that i like yours better. That's exactly why it would have been helpful if you added a refference to a more thorough explenation... – Uri Abramson Aug 21 '13 at 17:39
2

For smaller jobs, you can use Azure's WebJob facility, which runs within a web app (useful if you're doing background tasks on the same data that a front-end site is managing).

There's a nice breakdown here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/

WebJobs are pretty easy to get running, but don't have the power of Worker Roles. See the following for a comparison: Worker Role vs Web Job

Community
  • 1
  • 1
Savage
  • 2,296
  • 2
  • 30
  • 40
0

Yes, no problem, here is another nice and easy to follow example Get Started with Azure Cloud Services. It (also) clearly shows how to implement the WorkerRole. You can use the WebRole to manage your service.

Gerard
  • 2,649
  • 1
  • 28
  • 46
0

Here are the steps to install a windows service on Windows Azure running VM with Windows Server 2012 R2:

  • start your VM in Windows Azure Console and connect to it with Remote Desktop Connector
  • map your storage as a new drive in your VM:

    net use z: \mystorage.file.core.windows.net\endoint /u:myusername verylongkeythatendswith==

Storage key can be found in your Azure Management Console -> Storages -> Manage Access Keys

  • copy all the necessary installation files to the mapped storage (copy&paste)
  • copy nssm to a local drive (not z: as it uses MAFS file system and that cannot be accessed with low-level windows API commands)
  • Create a .bat file with the following entries

set username=xxx set password=yyy call d:\nssm install "My service" "%programfiles%\PathToService\myservice.exe" "-p 8677" d:\nssm set "My service" ObjectName "%username%" "%password%" sc failure "My service" actions= restart/60000/restart/60000/restart/60000 reset= 240 d:\nssm start "My service"

Username and password should be the ones you used to create the VM.

  • run the script. The service should be visible in your services list.

Enjoy!

PS : I used NSSM to simplify the service deployment.

luksmir
  • 3,104
  • 5
  • 22
  • 38
0

I would use web jobs for this, it's scheduling functionality and easy deployment/config makes this a trivial task. Zip up your .exe and upload it, then set a schedule and you're done.

Phil
  • 86
  • 5
-1

Yes u can , in the website there are a task web jobs y can create a batch, wsh, powershell(need the azure power shell) or using the web jobs API, rest API, on the other hand we have azure automation is similar but use work flow

  • Could you provide some screenshots or better explained examples of how to do this? This would help the asker more. – Strikeskids Aug 09 '15 at 17:19