Windows Azure SQL数据库上数据库的交叉订阅复制 [英] Cross Subscription Copying of Databases on Windows Azure SQL Database

查看:121
本文介绍了Windows Azure SQL数据库上数据库的交叉订阅复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将Windows Azure中的测试和生产实例分为两个单独的订阅.当前,我们有3个位于同一订阅中的Windows Azure SQL数据库实例:

We are about to split our testing and production instances in Windows Azure into two separate subscriptions. Currently we have 3 Windows Azure SQL Database instances that reside within the same subscription:

  • 生产
  • 报告
  • 测试

为了完全隔离生产,我们将其分为:

In order to completely isolate production we are splitting these into:

  • 生产订阅
    • 生产
    • 报告
    • Production Subscription
      • Production
      • Reporting
      • 测试

      目前,在混淆实时数据之前,我们使用CREATE DATABASE X AS COPY OF [ServerName].Y命令将数据库从生产环境复制到测试环境.只要数据库位于同一数据中心中并且我们在创建数据库的实例上具有共享登录名,就可以执行此操作(如本文所述).

      At the moment we use the CREATE DATABASE X AS COPY OF [ServerName].Y command to copy databases from production to testing before we obfuscate the live data. This operation can be performed so long as the databases are geo-located in the same data centre and we have a shared login across the instances that created the database in the first place (As indicated by this article).

      但是;本文没有指出源实例和目标实例是否需要属于相同订阅.假设我们使用一致的登录名,是否能够在生产订阅和测试订阅(以及vica verca)之间复制数据库?

      However; the article does not indicate whether the source and destination instance need to belong to the same subscription. Are we able to copy the database between the production subscription and testing subscription (And vica verca) assuming we use a consistent login?

      推荐答案

      我想您已经有了一个解决方案,但是对于在此登陆的任何人,您都可以使用Azure PowerShell API在源订阅中创建一个新服务器,并创建一个复制新服务器并将其切换到目标订阅

      I guess you already have a solution, however for anyone landing here, you can use the Azure PowerShell API's to Create a new server in the source subscription, create a copy and switch over the new server to the destination subscription

      可以在 technet

      该代码是自解释性的,但是出于SO最佳实践的考虑,

      The code is self explanatory, however in the interest of SO best practices,

      代码的关键部分是

      创建新服务器:

      $newserver = New-AzureSqlDatabaseServer -Location $targetServerLocation -AdministratorLogin $targetServerLoginID -AdministratorLoginPassword $targetServerLoginPassword 
      

      创建数据库副本:

      Start-AzureSqlDatabaseCopy -ServerName $sourceServerName -DatabaseName $sourceDatabaseName -PartnerServer $newserver.ServerName  -PartnerDatabase $targetdatabaseName  
      

      传输服务器

      $uri = "https://management.core.windows.net:8443/" + $sourceSubscriptionID + "/services" + "/sqlservers/servers/" + $newserver.ServerName + "?op=ChangeSubscription" 
      
      Invoke-RestMethod -Uri $uri -CertificateThumbPrint $certThumbprint -ContentType $contenttype -Method $method -Headers $headers -Body $body 
      

      这篇关于Windows Azure SQL数据库上数据库的交叉订阅复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆