In order to verify the deployment of my database scripts better, I'd like to pre-initialize my Staging database with a mirror image of the Production database as a first step in my Octopus deployment. I'm using SQL Azure and DACFX. I'm curious if anyone else has tried this...
- Is
Start-AzureSqlDatabaseCopy
the right PS cmdlet to use for this operation? - Will this effect the performance of my production environment?
- Are there any other options to consider?
Update
I developed the below script, which seems to work. However, I'm having trouble blocking completion of the script until the database is finished copying. At some point Get-AzureSqlDatabaseCopy
will throw an error (maybe Azure can't handle the load?).
Import-Module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\ServiceManagement\Azure\Azure.psd1'
$serverName = "..."
$sourceDbName = "..."
$targetDbName = "..."
$testdb = Get-AzureSqlDatabase -ServerName $serverName -DatabaseName $targetDbName -ErrorAction SilentlyContinue
IF (!$testdb)
{
Write-Host "TestDB Not Found"
}
ELSE
{
Remove-AzureSqlDatabase -ServerName $serverName -Database $testdb -Force
}
$dbCopy = Start-AzureSqlDatabaseCopy -ServerName $serverName -DatabaseName $sourceDbName -PartnerDatabase $targetDbName
WHILE ($dbCopy)
{
Write-Progress -Activity "Copying Database" -PercentComplete [int]$dbCopy.PercentComplete
$dbCopy = Get-AzureSqlDatabaseCopy -ServerName $serverName -DatabaseCopy $dbCopy
# Sleep 10 seconds
[System.Threading.Thread]::Sleep(10000);
}
Write-Host "Complete"
I'm still not convinced this is the right way to go & it seems to put a lot of load on Azure (wasn't able to log into my portal while this was running for some reason). Any thoughts would be appreciated...