I have a runbook that is creating a bacpac file for a database sending it to Blob Storage. I also have the Automation being monitored so that if it fails I get an alert. To test the alert I have configured the database to be backed up so that the creation of the backup fails which is what I see in the Import/export blade of the server.
But the runbook and automation gives a status of complete when it should be failing.
It seems that it reads the code for the backup connection and if that succeeds then it is Complete but the creation of the backup file actually fails.
The code I have is:
#create the bacpac file and land in the blob storage
$exportRequest = New-AzSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri
-AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password
#if bacpac fails then fail runbook so AZ Monitor error message is generated
$ErrorActionPreference = "Stop"
But I must be missing something.
Appreciate any thoughts.
wayne