0

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 :

enter image description here

3
  • Are you still facing the same issue? @AJ31 Commented Apr 1, 2024 at 12:07
  • Yes @Jahnavi, I am still facing this issue. Commented Apr 1, 2024 at 17:32
  • Have you checked the redirect URL format and whether you are given a right one? @AJ31 Commented Apr 2, 2024 at 5:42

1 Answer 1

0

How to list the databases/models under Azure Analysis Services using PowerShell: -

The type you are loading is not appropriate to list out the models on Azure Analysis Servers. Use New-Object Microsoft.AnalysisServices.Tabular.Server instead of New-Object Microsoft.AnalysisServices.Server.

Also check the inputs provided are correctly given without any conflicts.

I tried below script to achieve your requirement and worked as expected.

[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")
$serverName = "asazure://eastus.asazure.windows.net/myserverj"
Connect-AzAccount
$context = Set-AzContext -SubscriptionId "xxx"
$server = New-Object Microsoft.AnalysisServices.Tabular.Server
$server.Connect($serverName)
$server.Databases

Output:

enter image description here

$server.Databases | select Name

enter image description here

Sign up to request clarification or add additional context in comments.

8 Comments

Hello @Jahnavi, this is still giving me the same error. The redirect URI 'urn:ietf:wg:oauth:2.0:oob' specified in the request does not match the redirect URIs configured for the application '<app-id>'.
Firstly, Could you explain what is the purpose of that URL in the script? @AJ31
That's what is confusing to me. I am just passing the Analysis server name. The code fails at the $server.Connect($serverName) and that's when I get this error.
Are you trying to connect it through Azure AD authentication? @AJ31
Once you enter after giving connect server command, what is it showing? @AJ31
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.