Azure SQL Database
An Azure relational database service.
5,348 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can I catch error when analysis services refresh fail and insert in a sql azure database?
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"
}
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