I was wondering if anybody can provide some insight into getting a list of databases from a FailoverGroup. I am half way there but when iterating over the databases within a FailoverGroup, the databases are a bunch of strings (https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.sql.models.failovergroup.databases?view=azure-dotnet). I want to convert this into a database object but because this is represented as a fully qualified name this is proving to be a little difficult to do unless I start splitting the string and indexing parts of it.
For example, the database name is returned as /subscriptions/[subscription_id]/resourceGroups/[resource_group]/providers/Microsoft.Sql/servers/[sql_server]/databases/MyDatabaseName
When I use the cmdlet Get-AzureRmSqlDatabase passing the above string, it doesn't place nice saying it doesn't exist. I can get this to work if I were to split the string and extract the database name only but that seems a little overkill.
In a nutshell, is there a way to cast the value returned in FailoverGroup.Databases to an instance of Microsoft.Azure.Commands.Sql.Database.Model.AzureSqlDatabaseModel
I am using the following to get fail over groups if this helps.. Get-AzureRmSqlDatabaseFailoverGroup -ResourceGroupName $ResourceGroupName -ServerName $ServerName