gpt4 book ai didi

Azure ARM 模板 SQL Azure 数据库 Bacpac 导入在第二次部署时失败

转载 作者:行者123 更新时间:2023-12-03 00:31:35 24 4
gpt4 key购买 nike

我正在使用 New-AzureRmResourceGroupDeployment Powershell cmdlet 通过 Azure 资源模板部署到资源组。这是一个测试环境,因此我想从 .bacpac 文件恢复数据库,以便为数据库提供真实的数据量。

以下代码片段在第一次部署到此资源组时成功部署,因为不存在现有数据库,但在任何后续部署中都会失败。

{
"name": "[variables('databaseName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[variables('databaseServerName')]",
"[concat('Microsoft.Sql/servers/', variables('databases.ServerName'))]"
],
"tags": {
"displayName": "testDatabase"
},
"properties": {
"collation": "[variables('databaseCollation')]",
"edition": "[variables('databaseEdition')]",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "[variables('databaseServicePlan')]"
},
"resources": [
{
"name": "Import",
"type": "extensions",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[variables('databaseName')]"
],
"properties": {
"storageKeyType": "[variables('databaseBackupStorageKeyType')]",
"storageKey": "[parameters('databaseBackupStorageKey')]",
"storageUri": "[concat(parameters('databaseBackupStorageLocation'), '/', parameters('backupFileName'))]",
"administratorLogin": "[variables('databaseAdminLogin')]",
"administratorLoginPassword": "[variables('databaseAdminPassword')]",
"operationMode": "Import"
}
}
]
}

失败时的错误:

Resource Microsoft.Sql/servers/databases/extensions '[resource-group-name]/[database-name]/Import' failed with message 'The ImportExport operation with Request Id 'b1f54bdd-6c98-4feb-a86f-656a5c6f1cc5' failed due to 'Error encountered during the service operation. 

Data cannot be imported into target because it contains one or more user objects. Import should be performed against a new, empty database.

也许我误解了这些模板的部署方式 - 我以为 ARM 修补了环境。有谁知道如何通知 ARM 仅在这些资源的配置发生更改时创建/更新数据库(和子资源)?

或者,如果有更好的方法使用资源模板恢复数据库,我很想听听。

非常感谢任何帮助或建议!

提前致谢,

最佳答案

如错误消息所述,您只能将数据导入到空数据库或创建新数据库时。

您是否尝试每次将数据导入同一个数据库或每次导入新数据库?如果是后者,那么我将与团队中更熟悉 ARM 模板的成员协调来帮助修复模板中的错误。

关于Azure ARM 模板 SQL Azure 数据库 Bacpac 导入在第二次部署时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38265457/

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