1

I'm hosting my C# ASP.net website on azure currently, and i'm searching for a function that let's me execute code to change database entry's after x minutes after the request.

So i example:

User visits my website http://www.test.com/
Users leaves my site.
5 minutes later i change a variable in my database.

I already found something called WebJobs, but it's not the perfect fit.

  • Why are you changing a variable in your database in this way? The reason I ask is that you may be going about this backwards ... – twoleggedhorse Nov 12 '17 at 21:57
  • Perhaps logging the last time an action was performed by the user would be better, that way you don't need to run a process afterwards – twoleggedhorse Nov 12 '17 at 22:01
  • My website creates a temp e-mail account for the visitor. That email needs to be deleted after x minutes. @twoleggedhorse – Justinfailber Nov 13 '17 at 09:59

1 Answers1

1

Per my understanding, you could log the action into Azure Storage Queue and specify the interval of time from now during which the message will be invisible as follows:

queue.AddMessage(new CloudQueueMessage("hello world"), initialVisibilityDelay:TimeSpan.FromMinutes(5));

Then, you could work with WebJobs SDK to trigger your Azure queue storage. More details, you could refer to How to use Azure queue storage with the WebJobs SDK. Also, you could leverage Azure Functions Queue bindings to achieve the similar requirement, details you could follow here.

Moreover, you could also leverage the Scheduled messages from Azure Service Bus. Also, here is a similar issue, you could refer to the related code for sending a scheduled message. For processing the messages, you could refer to How to use Azure Service Bus with the WebJobs SDK or Azure Functions Service Bus bindings.

My website creates a temp e-mail account for the visitor. That email needs to be deleted after x minutes.

Per my understanding, when you creating the temp e-mail account, you could record the create time and the expire time, and valid the temp account is valid or not when accessing your website. Then you could create a Recurring job (e.g. azure webjobs (TimerTrigger), or Hangfire,etc) to retrieve the expired accounts and delete them.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35
  • So your answer is basicly: Create a message pool, and read that message pool every x minutes? – Justinfailber Nov 13 '17 at 10:01
  • My idea is that we could push the message to the pool and make the message visible after x minutes. The `QueueTrigger` for WebJobs and Service Bus trigger binding for Azure Functions would continuously monitor the pool, and automatically retrieve your message if it is visible. Please have a look at the tutorials in my answer. – Bruce Chen Nov 14 '17 at 01:40