Alan2
Alan2

Reputation: 24602

How can I make an ASP.NET WebAPI program running in an Azure instance update a database every minute?

I'm very familiar with using WebAPI to respond to incoming HTTP requests but now I have a new requirement and I'm not really sure where to start.

What I would like to do is to have my application once deployed to the cloud, establish a connection to a database and update a column every minute. The code needed to establish the connection and update the column is easy but my question is, where could I put this code? Is there some part of a normal ASP.NET WebAPI such as one of the start files where I could code this and how/where could I put a function call?

Upvotes: 0

Views: 120

Answers (3)

Abhay Saraf
Abhay Saraf

Reputation: 1212

Maybe you can try Azure Scheduler which you can simply configure to call your Web API every minute.

Upvotes: 1

shachar
shachar

Reputation: 599

I'm using Azure Function for a similar job - updating a DB every few minutes (in my case DocumentDB). It has a timer trigger where you can provide your Cron expression for timer based operations. https://azure.microsoft.com/en-us/documentation/articles/functions-bindings-timer/

The only problem I have is version control on the code that is deployed to the Azure Function.

It's actually built on top of the Azure Webjobs SDK , you can read about the differences here - Azure Webjobs vs Azure Functions : How to choose

Upvotes: 1

Benjamin Drolet
Benjamin Drolet

Reputation: 189

This sounds like a job for an Azure Worker Role or an Azure WebJob. Depending on the scope of what you want to do. Azure Web Role for something a little more complicated.

Upvotes: 1

Related Questions