问题
I understand that you are able to open port 80 on an Azure worker role and run a WCF service publicly. I am, however, having trouble coming up with a scenario where it makes more sense to do it this way as opposed to running in a web role. Any ideas?
回答1:
A WCF service hosted in a worker role will essentially be self-hosted: From your OnStart(), you'd create a new ServiceHost() and go from there.
A WCF service hosted in a web role would be taking advantage of IIS to host the service, as an svc, taking advantage of IIS performance counters, caching, automatic activation, process recycling, etc.
Even more interesting: In a web role where you host your website, you could still run a self-hosted WCF service the same way as in a worker role. You'll just need to create another input endpoint on some other port (or an internal endpoint, usable by only your Windows Azure web/worker role instances in your deployment).
And yet another scenario: By running a self-hosted service, you're not limited to .net - fire up any executable that knows how to listen to a port. This opens up opportunities to host a Java service host, python, etc.
来源:https://stackoverflow.com/questions/5971256/wcf-service-over-http-in-an-azure-worker-role