Catch error when analysis services refresh fail and insert in a sql azure database

Sasha Sasha 200 Reputation points
2023-12-31T14:01:59.5133333+00:00

How can I catch error when analysis services refresh fail and insert in a sql azure database?

Azure SQL Database
Azure Analysis Services
Azure Analysis Services
An Azure service that provides an enterprise-grade analytics engine.
443 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amira Bedhiafi 18,741 Reputation points
    2023-12-31T22:38:44.5833333+00:00

    If you are familiar with PowerShell, go for it. Here is an example :

    
    try {
    
        # Command to refresh Analysis Services
    
        Invoke-AsCmd -Server "your-ssas-server" -Query "your-refresh-command"
    
    } catch {
    
        # Capturing error details
    
        $errorDetails = $_.Exception.Message
    
        $timestamp = Get-Date
    
        # SQL to insert error details into the database
    
        $sql = "INSERT INTO ErrorLog (ErrorMessage, TimeStamp) VALUES ('$errorDetails', '$timestamp')"
    
        # Connect to Azure SQL Database and execute the insert command
    
        # Assumes you have a function or method to handle the SQL execution
    
        Execute-SqlCommand -Sql $sql -Server "your-sql-server.database.windows.net" -Database "your-database"
    
    }
    
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nandan Hegde 30,871 Reputation points MVP
    2023-12-31T15:51:08.7233333+00:00

    Hey, it depends on the way you are triggering the AAS refresh. In case of you are using azure data factory as the tool to trigger aas refresh, you can check the status of the aas refresh and then take necessary actions. In your case use script activity to write into database

    0 comments No comments