新しいAzureRmResourceGroupDeployment Powershellコマンドレットを使用して、Azureリソーステンプレートを使用してリソースグループに展開しています。これはテスト環境なので、データベースを.bacpacファイルから復元して、現実的な量のデータでデータベースをシードしたいと考えています。Azure ARMテンプレートSQL AzureデータベースBacpacのインポートが2回目の展開で失敗する
次のスニペットは、既存のデータベースは存在しないが後続のデプロイメントで失敗するため、このリソースグループへの最初のデプロイ時に正常にデプロイされます。
{
"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はインポートが実行できないことを認識してそのステップをスキップします。 – Rob