Search code examples
c#wcfazureazure-web-app-serviceazure-webjobs

How to communicate from Azure webjob to Azure webapp?


I'm running an Azure webjob alongside an Azure webapp. The job runs periodically and the result of the job is needed in the webapp. How do I get the result there?

I tried with a WCF netNamedPipeBinding but since there are no startup tasks for Azure webapps I cannot add a net.pipe binding to the IIS website nor can I enable the net.pipe protocol.

I have it working now with a basicHttpBinding but this binding is exposed to the entire internet which I absolutely do not want. I simply want machine-local communication between a webjob and webapp running on the same machine.

CORRECTION: I thought I had it working on Azure but that is not the case. When running on Azure I get an error from the webjob: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:80 (using basicHttpBinding). Probably the webapp has an internal port number I don't know.


Solution

  • You have a few options:

    1. Use the file system to pass messages
    2. Use Azure Storage Queues to pass messages between the two
    3. Use Azure Service Bus Queue to pass messages
    4. Use any shared storage (database, Azure Storage, etc) to pass messages

    The benefit of all these approaches is that it makes your message passing async and thus more resilient to one of the two services (web app or web job) going down for some time.