Using wizard 'Add Database to Availability Group' you may receive next error message:
Failed to join the database '<db-name>' to the availability group '<ag-name>' on the availability replica '<secondary-sql-server>'. (Microsoft.SqlServer.Smo) Availability-group DDL operations are permitted only when you are using the master database. Run the USE MASTER command, and retry your availability-group DDL command. (Microsoft SQL Server, Error: 35208)
It fails on executing last step of configuring database on secondary replica(s). It turned out that wizard doesn't add 'use [master]' statement into its script. Logical question is why don't we on master DB? Okay. Basically there are two options: in login properties of user and directly in SSMS connection properties.
In my case someone of our DBAs has changed 'Connect to database'. I changed it back to <default> which solved the problem.