I have a task that I need to automate. The task involves getting the list of Databases/Models present in the Azure Analysis Services model using Powershell Script
I have written the following Powershell script
$serverName = "ServerName"
$ResourceGroupName = "ResourceGroupName"
$server = Get-AzAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $serverName
$ServerName = $server.ServerFullName
Currently using the Get-AzAnalysisServicesServer doesn't return the models/database under it and I did not find any other command that could help me list the databases.
After doing some research I came across an article that suggested using Microsoft.AnalysisServices assembly.
# Load the Microsoft.AnalysisServices assembly
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
# Connect to the Azure Analysis Services server
$MyServer = New-Object Microsoft.AnalysisServices.Server
$MyServer.Connect($ServerName)
# Check if the server connection is successful
if ($MyServer.Connected) {
Write-Output "Connected to Azure Analysis Services server: $ServerName"
# Get the list of databases from the server
$Databases = $MyServer.Databases
# Check if there are databases present
if ($Databases.Count -gt 0) {
Write-Output "List of databases:"
foreach ($Database in $Databases) {
Write-Output $Database.Name
}
} else {
Write-Output "No databases found on the server."
}
} else {
Write-Output "Failed to connect to Azure Analysis Services server: $ServerName"
}
# Close the connection to the server
$MyServer.Disconnect()
Write-Output "Connection to Azure Analysis Services server closed."
Using the above script fails at the $MyServer.Connect($ServerName) with the following error:
AADSTS50011: The redirect URI 'some url' specified in the request does not match the redirect URIs configured for the application '<application_id>'. Make sure the redirect URI sent in the request matches one added to your application in the Azure portal.
Is there any other way to get the list of databases or this is not possible at all? Also, how can I fix the redirect URI issue as the application id mentioned in the error is not present in our Azure subscription.
Image for Error :


