azure - 使用 Azure 资源管理器复制 Azure SQL 数据库

标签 azure azure-sql-database azure-resource-manager

我当前正在使用 ARM 创建环境部署包,并且希望能够将现有的 Azure SQL 数据库(架构和数据)复制到新资源组中的另一个 Azure SQL 数据库。我从原始 SQL 数据库创建了一个 .bacpac 文件并将其上传到存储帐户中。然后,我将 SQL 数据库导入资源添加到我的模板中,并将其指向我创建的 .bacpac 文件的 URI。当我尝试运行部署时,出现此错误。

A project which specifies Microsoft Azure SQL Database v12 as the target platform cannot be published to Microsoft Azure SQL Database

 {
      "name": "[concat(parameters('environment'),'dbagg')]",
      "type": "databases",
      "location": "[resourceGroup().location]",
      "apiVersion": "2014-04-01-preview",
      "dependsOn": [
        "[variables('sqlServerName')]"
      ],
      "tags": {
        "displayName": "AggregationDatabase"
      },
      "properties": {
        "collation": "[parameters('AggregationDatabaseCollation')]",
        "edition": "[parameters('AggregationDatabaseEdition')]",
        "maxSizeBytes": "1073741824",
        "requestedServiceObjectiveName": "[parameters('AggregationDatabaseRequestedServiceObjectiveName')]"
      },
      "resources": [
        {
          "name": "Import",
          "type": "extensions",
          "apiVersion": "2014-04-01-preview",
          "dependsOn": [
            "[concat(parameters('environment'),'dbagg')]"
          ],
          "tags": {
            "displayName": "Copy Azure SQL DB"
          },
          "properties": {
            "storageKeyType": "Primary",
            "storageKey": "key",
            "storageUri": "https://test.blob.core.windows.net/databasefiles/AggregationServerDCT.bacpac",
            "administratorLogin": "[parameters('sqlAdminLogin')]",
            "administratorLoginPassword": "[parameters('sqlAdminLoginPassword')]",
            "operationMode": "Import"
          }
        }
      ]
    }

对此的任何帮助将不胜感激。

最佳答案

问题是您使用了错误的 storageKeyType 值。您需要使用StorageAccessKey

我使用这样的模板并且工作正常,我看到的唯一区别是这个键类型。

{
  "name": "[concat(variables('sqlServerName'), '/databasename/Import')]",
  "type": "Microsoft.Sql/servers/databases/extensions",
  "apiVersion": "[variables('sqlServerApiVersion')]",
  "tags": {
    "displayName": "Copy Azure SQL DB"
  },
  "properties": {
    "storageKeyType": "StorageAccessKey",
    "storageKey": "[listkeys(variables('storageId'), variables('storageVersion')).key1]",
    "storageUri": "[concat(parameters('_artifactsLocation'), '/database.bacpac')]",
    "administratorLogin": "[parameters('sqlServerAdminLogin')]",
    "administratorLoginPassword": "[parameters('sqlServerAdminLoginPassword')]",
    "operationMode": "Import"
  }
}

另请参阅有关所有属性和可能值的文档:https://msdn.microsoft.com/en-us/library/azure/mt683388.aspx .

关于azure - 使用 Azure 资源管理器复制 Azure SQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34360148/

相关文章:

azure - 逻辑应用 - "Authorization Failed - The authentication credentials are not valid"

Azure DevOps 发布管道变量值未更新

c# - Azure函数错误: Microsoft. Azure.WebJobs.Host : Error indexing method 'Function1' .无法将参数 'document'绑定(bind)到类型IAsyncCollector`

mysql - Laravel 无法连接到 Azure MySQL

c# - Entity Framework 插入性能

azure - 如何在 Azure 上使用来自不同存储帐户的自定义镜像创建虚拟机

Azure 独立应用服务环境无法使用 Terraform 创建,错误代码为 "An error has occurred."

Azure Cosmos DB 地理空间查找消耗的 RU 过高

Azure:联合已被弃用,那么如何实现 'custom sharding' ?

powershell - 我应该如何触发 ARM 部署