Availability group '%1!s!' cannot process the ALTER AVAILABILITY GROUP command, because the local availability replica is ...

Availability group '%1!s!' cannot process the ALTER AVAILABILITY GROUP command, because the local availability replica is not the primary replica.  Connect to the server instance that is currently hosting the primary replica of this availability group, and rerun the command.