Search code examples
phpazureazure-storage-queues

AzurePHP - Polling an Azure Queue


I have a PHP script that writes a file to an Azure Blob. Once the file is uploaded, logic in Azure performs computation and then places the result in the Blob. Upon completion, a message is PUT into an Azure Queue.

I'm trying to write code in php that polls the Queue, looking for a specific message indicating that the Result is ready to download. How would you approach this?


Solution

  • The only feasible way of doing that with PHP that I see following as possible solution to your issue:

    1. Create a small php file that checks the queue for messages and process them if any. Retrieve only one message at a time. Do not forget to delete the message after processing. When retrieving the message, get it with appropriate timeout to have enough time for processing.
    2. Create a small .bat (or .cmd) file that invokes the php.exe binary providing the path to your php file
    3. In a startup task configure Windows Task Scheduler to execute the batch file (.bat or .cmd) every N seconds/minutes

    Hope this helps!

    Add comment if you need any additional help, and I'll try to provide code samples. Everything is pretty trivial.