activate Service Broker on a database in an Availability Group
First, create and configure the service broker endpoint
select * from sys.tcp_endpoints

Create a new end point for the service broker:
CREATE ENDPOINT [Avaruu5alus]  
    STATE = STARTED  
    AS TCP  (LISTENER_PORT = 4022, LISTENER_IP = ALL )  
    FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS)  
    
GRANT CONNECT ON ENDPOINT::[Avaruu5alus] TO [PUBLIC] 

SQL Server Broker is not Multisubnet aware. You need to set RegisterAllProvidersIP to 0
Thereafter take the availability group offline and bring online again.
USE [master]
GO
ALTER DATABASE [Avaruu5alusDB] SET  ENABLE_BROKER WITH NO_WAIT
GO