Azure SQL 数据库和托管实例导入/导出服务需要很长时间来导入或导出数据库Azure SQL Database and Managed Instance Import/Export service takes a long time to import or export a database

适用于:是 Azure SQL 数据库 是Azure SQL 托管实例 APPLIES TO: yesAzure SQL Database yesAzure SQL Managed Instance

使用导入/导出服务时,相关过程花费的时间可能比预期要长。When you use the Import/Export service, the process might take longer than expected. 本文介绍此延迟的可能原因和替代解决方法。This article describes the potential causes for this delay and alternative workaround methods.

Azure SQL 数据库导入/导出服务Azure SQL Database Import/Export service

Azure SQL 数据库导入/导出服务是一项在每个 Azure 数据中心运行的基于 REST 的 Web 服务。The Azure SQL Database Import/Export service is a REST-based web service that runs in every Azure data center. 在 Azure 门户中使用导入数据库导出选项移动数据库时,会调用该服务。This service is called when you use either the Import database or Export option to move your database in the Azure portal. 此服务提供免费的请求排队和计算服务以在 Azure SQL 数据库和 Azure Blob 存储之间执行导入和导出操作。The service provides free request queuing and compute services to perform imports and exports between Azure SQL Database and Azure Blob storage.

这些导入和导出操作不代表传统的物理数据库备份,而是代表对使用特殊 BACPAC 格式的数据库进行的逻辑备份。The import and export operations don't represent a traditional physical database backup but instead a logical backup of the database that uses a special BACPAC format. 有了 BACPAC 格式,就不必使用 Microsoft SQL Server 版本、Azure SQL 数据库版本和 Azure SQL 托管实例版本之间可能存在差异的物理格式。The BACPAC format lets you avoid having to use a physical format that might vary between versions of Microsoft SQL Server, Azure SQL Database, and Azure SQL Managed Instance.

什么导致此过程中出现的延迟?What causes delays in the process?

Azure SQL 数据库导入/导出服务为每个区域提供有限数量的计算虚拟机 (VM) 来处理导入和导出操作。The Azure SQL Database Import/Export service provides a limited number of compute virtual machines (VMs) per region to process import and export operations. 计算 VM 按区域托管,确保导入或导出避免跨区域带宽延迟和收费。The compute VMs are hosted per region to make sure that the import or export avoids cross-region bandwidth delays and charges. 如果在同一区域中同时发出过多请求,则可能会在处理这些操作时出现显著延迟。If too many requests are made at the same time in the same region, significant delays can occur in processing the operations. 完成请求所需的时间可能短至数秒,也可能长达许多小时。The time that's required to complete requests can vary from a few seconds to many hours.

备注

如果某个请求未在四天内处理,此服务会自动取消该请求。If a request is not processed within four days, the service automatically cancels the request.

如果数据库导出仅用于从意外数据删除进行的恢复,则所有 Azure SQL 数据库版本都会提供从系统生成的备份进行自助还原的功能。If your database exports are used only for recovery from accidental data deletion, all the Azure SQL Database editions provide self-service restoration capability from system-generated backups. 但是,如果因为其他原因而需要这些导出,并且需要持续情况下更快或可预测性更强的导入/导出性能,请考虑以下选项:But if you need these exports for other reasons, and if you require consistently faster or more predictable import/export performance, consider the following options:

导出或导入数据库时要考虑的事项Things to consider when you export or import a database

  • 本文讨论的所有方法用光了数据库事务单位 (DTU) 配额,导致 Azure SQL 数据库服务进行相关限制。All the methods discussed in this article use up the Database Transaction Unit (DTU) quota, which causes throttling by the Azure SQL Database service. 可以在 Azure 门户中查看数据库的 DTU 统计信息You can view the DTU stats for the database on the Azure portal. 如果数据库达到其资源限制,请升级服务层级以添加更多资源。If the database has reached its resource limits, upgrade the service tier to add more resources.
  • 理想情况下,应该在数据库所在区域的 VM 中运行客户端应用程序(例如 sqlpackage 实用工具或自定义 DAC 应用程序)。Ideally, you should run client applications (like the sqlpackage utility or your custom DAC application) from a VM in the same region as your database. 否则,可能会遇到与网络延迟相关的性能问题。Otherwise, you might experience performance issues related to network latency.
  • 在没有聚集索引的情况下导出大型表可能会很慢,甚至会导致故障。Exporting large tables without clustered indexes can be very slow or even cause failure. 出现此行为的原因是:表不能拆分,因此无法以并行方式导出,This behavior occurs because the table can't be split up and exported in parallel. 而只能在单个事务中导出,这导致在导出过程中出现性能降低的情况,并且存在故障的可能,大型表尤其如此。Instead, it must be exported in a single transaction, and that causes slow performance and potential failure during export, especially for large tables.

导出数据库时的注意事项Considerations when exporting a database