0

我使用 powershell 从 bacpac 文件创建 SQL Azure 数据库。但是,当数据库大小超过默认的最大大小时,有时我会遇到麻烦。

根据文档,应该可以将数据库大小添加到 ImportBacpac 方法,但我不确定如何在 powershell 中使用它。

任何正在使用更改的数据库最大大小恢复数据库的人?

文档:http ://technet.microsoft.com/en-us/library/jj870786.aspx

当前代码

function restore-SQLBackup
([string]$ConnectionString = $(throw "The ConnectionString parameter is required."), 
[string]$DatabaseName = $(throw "The databaseName parameter is required."),
[string]$fileName = $(throw "The fileName parameter is required."), 
[string]$microsoftSqlServerDacPath = "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.SqlServer.Dac.dll") {

Add-Type -Path $microsoftSqlServerDacPath

$Services = new-object Microsoft.SqlServer.Dac.DacServices $ConnectionString

if ($Services -eq $null)
{
    exit
}

$timeStamp = (Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")

$bacpac = [Microsoft.SqlServer.Dac.BacPackage]::Load($fileName)
Write-Host "Starting restoring $DatabaseName at $timeStamp"
$Watch = New-Object System.Diagnostics.StopWatch
$Watch.Start()
$Services.ImportBacpac($bacpac, $DatabaseName)
$Watch.Stop()
Write-Host "Restore completed in" $Watch.Elapsed.ToString()
}
4

1 回答 1

1

尝试更改为:

$Watch.Start() 
$DatabaseSpecifications = New-Object Microsoft.SqlServer.Dac.DacAzureDatabaseSpecification
$DatabaseSpecifications.MaximumSize = 5 #5GB, based on your need
$Services.ImportBacpac($bacpac, $DatabaseName,$DatabaseSpecifications)
$Watch.Stop()

这是我使用的文档:http ://technet.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacazuredatabasespecification.maximumsize.aspx

这是用于一般数据库调整大小的 cmdlet:http: //msdn.microsoft.com/en-us/library/windowsazure/jj983732.aspx

于 2013-10-08T07:30:23.650 回答