I'm trying to monitor an ongoing database copy, (Start-AzureSqlDatabaseCopy). I've set up the following:
$dbCopy = Start-AzureSqlDatabaseCopy -ServerName $serverName -DatabaseName $sourceDbName -PartnerDatabase $targetDbName -PartnerServer $serverName
WHILE ($dbCopy)
{
$dbCopy = Get-AzureSqlDatabaseCopy -ServerName $serverName -DatabaseCopy $dbCopy
Write-Host $dbCopy.ReplicationStateDescription
[System.Threading.Thread]::Sleep(1000);
}
The state is pending (the first approx. 7 times) and then returns an exception of "resource does not exist". The database gets copied ok, but how do I monitor with script?'
This is where I got the general outline of the approach (https://stackoverflow.com/a/25268033/4261741)
ReplicationStateDescriptioneventually?Get-AzureSqlDatabaseCopycommand might fail as the copy process doesn't exist any moremessageproperty. If it's notresource does not existthen re-throw or handle some other way.