1. Backup the primary instance database belonging to Availability Group
2. Restore the backed up primary instance database on the primary instance.
We get the error
System.Data.SqlClient.SqlError: RESTORE cannot operate on database 'AG_DENALI' because it is configured for database mirroring or has joined an HADR Availability Group. Use ALTER DATABASE to remove mirroring or to unjoin from its Availability Group if you intend to restore the database. (Microsoft.SqlServer.Smo)
We are unable to get the query (ALTER DATABASE) to remove mirroring or to unjoin from its availability group.