sql-serverazurecachingazure-sql-database

Is there equivalent of SQLdependency in AzureSQL?


I have two apps. One inserts into AzureSQL DB and other reads. I want second app to cache query results and invalidate cache only when something changed in table/query results. In standalone SQL Server it was possible by SQLDependency (or SQLCacheDependency) mechanism. As far as I understood, in AzureSQL this mechanism is unavailable. It requires ServiceBroker component to be enabled, and there's no such component in Azure SQL.

I apoligize if I reapeat already asked questions, but all answers come from 2012 or so. Were there any changes? It's 2017.

And the questions is, what is the mechanism to inform application (say, ASP.NET) about changes in AzureSQL?

PS: I know there's related feature "ChangesTracking", but it is about inserting records about some other changes in speical table. That is "within" database. I need to inform app outside of DB.


Solution

  • To my understanding, SQLDependency works by using DependencyListener, that is an implementation of RepositoryListener and relays on ServiceBroker, as you stated AzureSQL does not support ServiceBroker. But you could use the PollingListener implementation of RepositoryListener to verify a change.

    "The PollingListener will run until cancelled and will simply compare the result of the query against until change is detected. Once it is detected, a callback method will be called"

    (Source1) (Source 2)