快速入门:使用 ARM 模板创建 Azure 数据库迁移服务的实例Quickstart: Create instance of Azure Database Migration Service using ARM template

使用此 Azure 资源管理器模板(ARM 模板)部署 Azure 数据库迁移服务实例。Use this Azure Resource Manager template (ARM template) to deploy an instance of the Azure Database Migration Service.

ARM 模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. 该模板使用声明性语法,使你可以声明要部署的内容,而不需要编写一系列编程命令来进行创建。The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it.

如果你的环境满足先决条件,并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. Azure 门户中会打开模板。The template will open in the Azure portal.

部署到 AzureDeploy to Azure

先决条件Prerequisites

Azure 数据库迁移服务 ARM 模板需要以下各项:The Azure Database Migration Service ARM template requires the following:

查看模板Review the template

本快速入门中使用的模板来自 Azure 快速启动模板The template used in this quickstart is from Azure Quickstart Templates.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "serviceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the new migration service."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location where the resources will be deployed."
            }
        },
        "vnetName": {
            "type": "string",
            "metadata": {
                "description": "Name of the new virtual network."
            }
        },
        "subnetName": {
            "type": "string",
            "metadata": {
                "description": "Name of the new subnet associated with the virtual network."
            }
        }
    },
    "variables": {
    },
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2020-04-01",
            "name": "[parameters('vnetName')]",
            "location": "[parameters('location')]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                }
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/subnets",
            "apiVersion": "2020-04-01",
            "name": "[concat(parameters('vnetName'), '/', parameters('subnetName'))]",
            "dependsOn": [
                "[parameters('vnetName')]"
            ],
            "properties": {
                "addressPrefix": "10.0.0.0/24"
            }
        },
        {
            "type": "Microsoft.DataMigration/services",
            "apiVersion": "2018-07-15-preview",
            "name": "[parameters('serviceName')]",
            "location": "[parameters('location')]",
            "sku": {
                "tier": "Standard",
                "size": "1 vCores",
                "name": "Standard_1vCores"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
            ],
            "properties": {
                "virtualSubnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
            }
        }
    ],
    "outputs": {
    }
}

该模板中定义了三个 Azure 资源:Three Azure resources are defined in the template:

可以在快速入门模板库中找到更多 Azure 数据库迁移服务模板。More Azure Database Migration Services templates can be found in the quickstart template gallery.

部署模板Deploy the template

  1. 选择下图登录到 Azure 并打开一个模板。Select the following image to sign in to Azure and open a template. 使用该模板创建 Azure 数据库迁移服务实例。The template creates an instance of the Azure Database Migration Service.

    部署到 AzureDeploy to Azure

  2. 选择或输入以下值。Select or enter the following values.

    • 订阅:选择 Azure 订阅。Subscription: Select an Azure subscription.
    • 资源组:从下拉列表中选择现有资源组,或者选择“新建”来创建新的资源组。Resource group: Select an existing resource group from the drop down, or select Create new to create a new resource group.
    • 区域:将在其中部署资源的位置。Region: Location where the resources will be deployed.
    • 服务名称:新迁移服务的名称。Service Name: Name of the new migration service.
    • 位置:资源组的位置,保留为默认值 [resourceGroup().location]Location: The location of the resource group, leave as the default of [resourceGroup().location].
    • Vnet 名称:新虚拟网络的名称。Vnet Name: Name of the new virtual network.
    • 子网名称:与虚拟网络关联的新子网的名称。Subnet Name: Name of the new subnet associated with the virtual network.
  3. 选择“查看 + 创建”。Select Review + create. 成功部署 Azure 数据库迁移服务实例后,你会收到通知。After the instance of Azure Database Migration Service has been deployed successfully, you get a notification.

使用 Azure 门户部署模板。The Azure portal is used to deploy the template. 除了 Azure 门户,还可以使用 Azure PowerShell、Azure CLI 和 REST API。In addition to the Azure portal, you can also use the Azure PowerShell, Azure CLI, and REST API. 若要了解其他部署方法,请参阅部署模板To learn other deployment methods, see Deploy templates.

查看已部署的资源Review deployed resources

可以使用 Azure CLI 查看已部署的资源。You can use the Azure CLI to check deployed resources.

echo "Enter the resource group where your SQL Server VM exists:" &&
read resourcegroupName &&
az resource list --resource-group $resourcegroupName 

清理资源Clean up resources

不再需要时,可使用 Azure CLI 或 Azure PowerShell 删除资源组:When no longer needed, delete the resource group by using Azure CLI or Azure PowerShell:

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

后续步骤Next steps

有关引导你完成模板创建过程的分步教程,请参阅:For a step-by-step tutorial that guides you through the process of creating a template, see:

有关部署 Azure 数据库迁移服务的其他方式,请参阅:For other ways to deploy Azure Database Migration Service, see:

若要了解详细信息,请参阅 Azure 数据库迁移服务概述To learn more, see an overview of Azure Database Migration Service