• From https://msdn.microsoft.com/en-us/library/ff878601.aspx about ALTER AVAILABILITY GROUP...FAILOVER:

    Initiates a manual failover of the availability group without data loss to the secondary replica to which you are connected[/i].

    (my emphasis)

    The problem is as the error message indicates. You're requesting a failover to an instance that is already the primary.

    The simplest way to do what you're wanting is to have the job run on Server-1, and check if it is the secondary. If it is, initiate failover to Server-1.

    Having said that about the specific error you're getting, I'm not so sure you necessarily want to automatically fail back to Server-1 any time there is a failover to Server-2. If the failover occurs because there is real problem with Server-1, you should probably want to keep Server-2 as the primary until Server-1 has been investigated and a cause for the initial failover determined.

    I'd prefer just raising an alert/sending an email on failover, so the cause can be investigated and any necessary fixes implemented prior to failing back to Server-1.

    Cheers!