https://eitanblumin.com/2020/05/26/sql-jobs-based-on-hadr-role-next-level/
Control SQL Jobs based on HADR Role - Taking it to the Next Level