gpt4 book ai didi

c# - .NET Core 2 C# - SQL Azure 时间点还原

转载 作者:太空宇宙 更新时间:2023-11-03 22:44:17 25 4
gpt4 key购买 nike

我需要以编程方式从 .NET Core 2.1 C# 函数恢复 SQL Azure 数据库。上 Recover an Azure SQL database using automated database backups文章展示了如何使用 PowerShell 或 REST API 来完成此操作。我发现了什么in C#不适用于 .NET Core。

你有什么建议吗?

谢谢。

最佳答案

您可以调用 REST API 并使用 PointInTimeRestore 作为 CreateMode .

PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.

更多信息可在此处找到:Databases - Create Or Update 。请务必查看 examples

例如,这将从 PointInTimeRestore 创建一个数据库:

请求:

PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbpitr?api-version=2017-10-01-preview

正文:

{
"location": "southeastasia",
"sku": {
"name": "S0",
"tier": "Standard"
},
"properties": {
"createMode": "PointInTimeRestore",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"restorePointInTime": "2017-07-14T05:35:31.503Z"
}
}

编辑:
您可以尝试Microsoft.Azure.Management.SQL NuGet package 。支持的框架是基于 NetCore 框架的 .NET Framework 4.5.2 和 Netstandard 1.4。

编辑2:
由于 Microsoft.Azure.Management.SQL NuGet 包是预发布版本,因此请确保您已选中“包括预发布”复选框已选中

为我工作:

Include prerelease shows NuGet package

关于c# - .NET Core 2 C# - SQL Azure 时间点还原,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50731721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com