您如何检查 Azure 中 SQL 导入导出操作的状态?

How do you check the status of a SQL Import Export Operation in Azure?

我正在使用 REST 管理 API 使用 BacPac 文件向 Azure 执行 SQL 数据库导入。我需要能够检查导入的状态,因为 Azure 不允许我在导入成功时发送事件。

这是我正在执行的操作的文档: https://docs.microsoft.com/en-us/rest/api/sql/databases%20-%20import%20export/import

我已经尝试使用 Azure 的 Analysis Services API 通过操作 ID 和它发生的区域来检查操作的状态。但是调用此端点返回 404 not found。

这是 Azure 分析服务 API 端点的文档,我正尝试使用我的导入操作 ID 及其发生的区域进行调用: https://docs.microsoft.com/en-us/rest/api/analysisservices/servers/listoperationresults

我期待 Analysis Services 为我提供我开始使用 Azure 管理 API 的 import/export 操作的状态。这样做会导致 404,所以我不确定我是否调用了正确的 API 端点(我仔细检查以确保我正在构建的 URI 中没有拼写错误以检查操作状态) .

如果您改用 PowerShell,我确实知道如何跟踪 import/export 操作的进度,但我不知道使用 Azure REST API.[=11 跟踪进度的方法=]

如果您使用 PowerShell New-AzureRmSqlDatabaseImport cmdlet to import a database or you use New-Azure​RmSql​Database​Export to export a database then you can use Get-AzureRmSqlDatabaseImportExportStatus 跟踪 import/export 操作的进度。

我找到一篇文章 Azure SQL Database Export,它谈到了如何使用 Microsoft Azure SQL 数据库 Import/Export REST 服务 API 检查导出状态。

总结:

在管理门户中,单击数据库,仪表板将显示最近的导出状态。在屏幕截图 5 中,您会看到我的数据库的 AUTOMATED EXPORT 状态显示为 NEVER EXPORTED。一旦成功导出,这将改变。 在管理门户中,单击数据库,仪表板将显示最近的导出状态。

最终计划在凌晨 1 点完成导出后,5 分钟后完成,我的仪表板中的自动导出状态显示相同。 (参见屏幕截图 6)。

希望对您有所帮助。

根据微软的说法:

“我们有 REST API 用于 Import/Export 到 Azure sql 的操作,但我们没有任何 REST API 可以找到 Import/Export状态。客户应使用 Powershell 获取状态

我还发现使用 Powershell 命令无法知道导入是否失败,因为它没有用于检查导入状态的数据库 uri(因为导入失败)。

对于任何api,例如BeginX(),都有对应的api X()等待完成。在这种情况下,而不是 BeginImport() use Import().

如果你希望更直接的控制轮询,那么可以查看Import的定义,直接使用下层,即BeginImportWithHttpMessagesAsync() and then GetPostOrDeleteOperationResultAsync():

        public async Task<AzureOperationResponse<ImportExportResponse>> ImportWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, ExportRequest parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Send request
            AzureOperationResponse<ImportExportResponse> _response = await BeginImportWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters, customHeaders, cancellationToken).ConfigureAwait(false);

            // Poll for completion
            return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
        }

这个答案是专门针对 .net 的,但同样的原则也适用于其他语言。

要监控导入进度,请打开数据库的服务器页面,然后在“设置”下,select Import/Export 历史记录。成功时,导入状态为已完成。

https://docs.microsoft.com/bs-latn-ba/azure/sql-database/sql-database-import?view=azureipps&tabs=azure-powershell

在数据库中转到概述 -> 在底部检查通知 -> 你确实点击了图像