質問

I've created a personal blog using Azure Websites.

Whenever I create a blog post I'd like to automatically generate a tweet saying something like "Hey check out my latest blog post myblog.net"

I could easily do this in my application layer when I save the new post. But it's not really the responsibility of the website to post the twitter link.

What I'd like to do is use a WebJob to do the post to twitter, but I can't figure out an appropriate way to trigger it. The website uses an sql database, and I've read that WebJobs can't be triggered by sql storage.

So I can think of two different solutions:

  1. The data access layer of my website also saves to Azure Table/Blob storage.
  2. The web job periodically polls the sql database

What is the 'best' approach?

I know this is a pretty trivial problem, I'm just trying to try out different technologies and thought that posting to twitter was appropriate for trying out web jobs

役に立ちましたか?

解決

I would suggest using the Azure WebJobs SDK with Azure Storage Queues: when a new post is published, your data layer can post a message in a Storage Queue. Then, you have a job that gets triggered by messages in that queue and posts on Twitter.

他のヒント

Since you're already using SQL database I would suggest using it for this to, for example you can just add a column to the posts table on whether the post was twitted on or not and the WebJob can periodically check for post not being twitted yet.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top