If you are wondering how to delay the visibility of a message in an Azure Storage Queue you are in the right article. It often occurs in some business scenarios that a request submitted by a user needs to be reviewed for approval or to check the status of it for example. I recently had a use case where the user had to confirm the insertion made within 3 days.
If you are familiar with Azure Functions, it should be typical for you the usage of the storage account (Blob, Queue, Table..), in particular of queues, I use very often this component as a trigger.
Now let say that a user receives a notification across an Azure Function and after that this info is stored in an Azure table, he needs to provide an action within 3 days. When you save a message in a queue this is immediately visible by triggering, for example, another function. The Azure SDK provides the method “AddMessage” with the property “initialVisibilityDelay” to determine when the message will appear. Below you can see the super complex code snippet of an Azure C# Function in order to do that:
The good things is that the approach works by respecting the concept of “serverless”.
Source code of the solution on my GitHub repo: https://github.com/giuleon/QueueVisibility