无法使用 Azure 门户导入数据库

Cannot Import DB using the Azure Portal

我正在尝试在 Azure 门户中导入数据库。我从中导出的原始数据库位于不同的服务器上,但设置与我尝试导入的位置相同。我通过转到目标服务器并单击导入按钮来导入。然后我选择要导入的存储帐户、容器和 bacpac 文件。我检查导入的数据库大小和类型是否与 bacpac 文件相同。我还仔细检查了导入的排序规则是否与 bacpac 中的排序规则相同。然后我确认。在给出以下错误消息之前,它会尝试导入大约 20 分钟。当我转到 sql 服务器并单击 sql 数据库边栏选项卡时,我可以看到数据库已创建,但数据库中的表是空的。

Could not import package.
Warning SQL72012: The object [data_0] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClie

我看到一些关于类似问题的回复,但他们似乎都在使用 SSMS。有没有人对如何在 Azure 门户中解决此问题有任何想法?另外,有谁知道他们在说什么复选框?我做导入设置的时候没有复选框。

您收到的警告有点转移注意力。问题在于您收到的错误。您发布的行只显示了一个一般错误,后面应该是实际错误。尝试转到实际的数据库服务器并检查 import\export 历史记录。

也尝试使用 powershell 进行导入,这可能会为您提供有关您遇到的错误的更多详细信息:

$importStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $importRequest.OperationStatusLink

[Console]::Write("Importing")
while ($importStatus.Status -eq "InProgress") {
    $importStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $importRequest.OperationStatusLink
    [Console]::Write(".")
    Start-Sleep -s 10
}

[Console]::WriteLine("")
$importStatus

在不知道您收到的错误是什么的情况下,试图猜测问题所在有点像摸黑。给出要从中导出的 SQL 的版本,我猜这是一个预置数据库服务器。

导入时 dacpac 文件往往会失败的常见原因之一是您的源数据库服务器未配置为允许 contained databases

如果是这种情况,您需要转到源数据库服务器(您从中导出的服务器)并启用该选项:

sp_configure 'contained database authentication', 1;  
GO  
RECONFIGURE;  
GO

一旦这是 运行,请重新创建您的 dacpac 文件并尝试导入它。

正如我所提到的,这完全是无稽之谈,因为您没有提供实际收到的错误信息