AlwaysOn Availability Groups are a high-availability and disaster-recovery feature introduced with SQL Server 2012, providing enhancements and abilities over database mirroring. An Availability Group protects a set of user databases, supporting up to eight secondary replicas of the primary database. In the event of a failure on the primary, all of the databases within an Availability Group will fail over together and become active on the designated failover partner. Additionally, you can configure secondary replicas to allow read-only activity and most backup operations, potentially taking some of the load away from the primary.
You want to execute script against database only if actual database is primary replica? Sometimes you need to continue execution of batch only when actual database is primary replica on...
Sometimes you need to reinitialize data movement in Availability Group. You can do that by right clicking Availability Database in SSMS then clicking "Suspend Data Movement" then clicking "Resume Data...
Return actual state of local replica connectivity to other replicas in Availability Group. Can be useful for fast check or in some automation or inventory solution....