jt0*_*000 2 powershell continuous-integration system-testing octopus-deploy azure-sql-database
为了更好地验证数据库脚本的部署,我想使用生产数据库的镜像预初始化我的Staging数据库,这是我的Octopus部署的第一步.我正在使用SQL Azure和DACFX.我很好奇是否有其他人试过这个......
Start-AzureSqlDatabaseCopy
正确的PS cmdlet用于此操作?更新
我开发了下面的脚本,似乎有效.但是,在数据库完成复制之前,我无法阻止脚本的完成.在某些时候Get-AzureSqlDatabaseCopy
会抛出错误(也许Azure无法处理负载?).
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"
Run Code Online (Sandbox Code Playgroud)
我仍然不相信这是正确的方法,它似乎给Azure带来了很大的负担(由于某种原因,它无法登录我的门户网站).任何想法将不胜感激......
我想我会回复这个进展如何.我将以下脚本添加到我的UAT(临时)环境的八达通步骤中,并且它已经运行得非常好.原始脚本的主要问题是我的调用Write-Progess
是一个错误的参数(我刚刚删除了调用,因为它无论如何都不会在Octopus中正常工作).
有一点需要注意的是,我必须让我的触手作为我的用户运行.我无法想办法让azure脚本在本地系统下运行.
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)
{
$dbCopy = Get-AzureSqlDatabaseCopy -ServerName $serverName -DatabaseCopy $dbCopy
# Sleep 10 seconds
[System.Threading.Thread]::Sleep(10000);
}
Write-Host "Complete"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
868 次 |
最近记录: |