Search code examples
azureazure-sql-databaseazure-management-api

Find Azure SQL replication problems through an API?


We are using Azure SQL as our database across multiple regions, with one primary and multiple secondaries.

The scenario is, we want to find if there are any active replication problems through some sort of API call / so we can integrate this into our overall environment.

Is there an Azure Management API / or SQL query we can run and build an API on top of - so we can some result like replica DB X is having problems and the data is outdated?


Solution

  • Azure doesn't have an API for this yet. But you should be able to build APIs on top of the views.

    There are out of box views 'sys.dm_database_replica_states' and 'sys.dm_db_resource_stats' provided on Azure SQL Database that could be used for your requirement. However, I would recommend you to go through the below link and choose them appropriately: https://learn.microsoft.com/en-us/azure/azure-sql/database/read-scale-out#monitoring-and-troubleshooting-read-only-replicas

    https://learn.microsoft.com/en-us/azure/azure-sql/database/read-scale-out#data-consistency