I am trying to setup SQL agent job that will only execute if it is primary replica of Azure SQL MI of failover groups.
I am trying to get primary replica using sys.dm_hadr_database_replica_states where is_primary_replica =1 but when I run it on SQL MI in different region , it also returns value 1.
I am using dbo.fn_hadr_group_is_primary(@AGName)=1 function for on-prem so looking for something similar for Azure SQL MI.