有人知道如何复制SQL Azure数据库到我的开发机器吗?我不想再花钱在云端建立开发数据库,但这是获得生产数据的最佳方式。我将我的生产数据库复制到一个新的开发数据库,但我想在本地拥有相同的数据库。
有什么建议吗?
有人知道如何复制SQL Azure数据库到我的开发机器吗?我不想再花钱在云端建立开发数据库,但这是获得生产数据的最佳方式。我将我的生产数据库复制到一个新的开发数据库,但我想在本地拥有相同的数据库。
有什么建议吗?
当前回答
您可以使用新的Azure移动服务执行夜间备份导出,从SQL Azure导出到Azure存储托管的.bacpac文件。这个解决方案是100%的云计算,不需要第三方工具,也不需要本地托管的SQL Server实例来下载/复制/备份任何东西。
大约有8个不同的步骤,但都很简单: http://geekswithblogs.net/BenBarreth/archive/2013/04/15/how-to-create-a-nightly-backup-of-your-sql-azure.aspx
其他回答
我无法让SSIS导入/导出工作,因为我得到了错误“插入只读列“id”失败”。我也不能让http://sqlazuremw.codeplex.com/工作,上面的链接到SQL Azure数据同步不适合我。
但我发现了一篇关于BACPAC文件的优秀博客文章:http://dacguy.wordpress.com/2012/01/24/sql-azure-importexport-service-has-hit-production/
在这篇博文的视频中,作者介绍了六个步骤:
Make or go to a storage account in the Azure Management Portal. You'll need the Blob URL and the Primary access key of the storage account. The blog post advises making a new container for the bacpac file and suggests using the Azure Storage Explorer for that. (N.B. you'll need the Blob URL and the Primary access key of the storage account to add it to the Azure Storage Explorer.) In the Azure Management Portal select the database you want to export and click 'Export' in the Import and Export section of the ribbon. The resulting dialogue requires your username and password for the database, the blob URL, and the access key. Don't forget to include the container in the blob URL and to include a filename (e.g. https://testazurestorage.blob.core.windows.net/dbbackups/mytable.bacpac). After you click Finish the database will be exported to the BACPAC file. This can take a while. You may see a zero byte file show up immediately if you check in the Azure Storage Explorer. This is the Import / Export Service checking that it has write access to the blob-store. Once that is done you can use the Azure Storage Explorer to download the BACPAC file and then in the SQL Server Management Studio right-click your local server's database folder and choose Import Data Tier Application that will start the wizard which reads in the BACPAC file to produce the copy of your Azure database. The wizard can also connect directly to the blob-store to obtain the BACPAC file if you would rather not copy it locally first.
最后一步可能只能在SQL Server Management Studio的SQL Server 2012版(我正在运行的版本)中使用。这台机器上没有更早的。在博客文章中,作者使用命令行工具DacImportExportCli.exe进行导入,我相信可以在http://sqldacexamples.codeplex.com/releases上找到
您也可以在Windows Azure管理门户中检查SQL Azure数据同步。它允许您检索和恢复整个数据库,包括SQL Azure和SQL Server之间的模式和数据。
看来2022年的Management Studio缺少功能了。下面是我如何使用Azure Data Studio:
安装Azure Data Studio Open Azure Data Studio 安装名为Admin Pack for SQL Server的扩展 重启Azure Data Studio 为源数据库(Azure)和目标数据库(本地机器)设置连接 在主数据库的本地DB引擎中执行语句:
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
右键单击源数据库并选择数据层应用程序向导 选择导出到。bacpac文件[导出bacpac](第四,在我的当前版本的最后一个选项) 完成向导 右键单击目标数据库并选择数据层应用程序 Wizzard 选择Import from .bacpac [Import bacpac](我的版本中的第三个选项) 选择先前创建的.bacpac文件并完成向导
在导入登录名和用户之后,创建了登录名和用户,但是没有设置它们的默认模式。如果需要默认的shcema,则需要手动处理。在这种情况下: 打开到本地副本的管理连接并运行: 使用[imported-db];ALTER USER - import - USER WITH DEFAULT_SCHEMA
您可以尝试使用“SQL数据库迁移向导”工具。 这个工具提供了从azure sql导入和导出数据的选项。
详情请点击这里。
https://sqlazuremw.codeplex.com/
将Azure数据库数据复制到本地数据库: 现在你可以使用SQL Server Management Studio来完成如下操作:
连接到SQL Azure数据库。 在对象资源管理器中右键单击数据库。 选择“任务”/“部署数据库到SQL Azure”选项。 在“部署设置”步骤中,连接本地SQL Server并创建新数据库。
"Next" / "Next" / "Finish"