クイック スタート:ARM テンプレートを使用して Azure SQL Managed Instance を作成する

このクイック スタートでは、Azure Resource Manager テンプレート (ARM テンプレート) をデプロイして Azure SQL Managed Instance と VNet を作成する過程を中心に取り上げます。 Azure SQL Managed Instance は、完全に管理されたインテリジェントでスケーラブルなクラウド データベースであり、SQL Server データベース エンジンとほぼ 100% の機能パリティを備えています。

ARM テンプレートは JavaScript Object Notation (JSON) ファイルであり、プロジェクトのインフラストラクチャと構成が定義されています。 このテンプレートでは、宣言型の構文が使用されています。 宣言型の構文では、デプロイしようとしているものを、デプロイを作成する一連のプログラミング コマンドを記述しなくても記述できます。

環境が前提条件を満たしていて、ARM テンプレートの使用に慣れている場合は、 [Azure へのデプロイ] ボタンを選択します。 Azure portal でテンプレートが開きます。

Deploy to Azure

前提条件

Azure サブスクリプションをお持ちでない場合は、無料アカウントを作成してください。

テンプレートを確認する

このクイックスタートで使用されるテンプレートは Azure クイックスタート テンプレートからのものです。

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.17.1.54307",
      "templateHash": "2861010078937229146"
    }
  },
  "parameters": {
    "managedInstanceName": {
      "type": "string",
      "metadata": {
        "description": "Enter managed instance name."
      }
    },
    "administratorLogin": {
      "type": "string",
      "metadata": {
        "description": "Enter user name."
      }
    },
    "administratorLoginPassword": {
      "type": "securestring",
      "metadata": {
        "description": "Enter password."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Enter location. If you leave this field blank resource group location would be used."
      }
    },
    "virtualNetworkName": {
      "type": "string",
      "defaultValue": "SQLMI-VNET",
      "metadata": {
        "description": "Enter virtual network name. If you leave this field blank name will be created by the template."
      }
    },
    "addressPrefix": {
      "type": "string",
      "defaultValue": "10.0.0.0/16",
      "metadata": {
        "description": "Enter virtual network address prefix."
      }
    },
    "subnetName": {
      "type": "string",
      "defaultValue": "ManagedInstance",
      "metadata": {
        "description": "Enter subnet name."
      }
    },
    "subnetPrefix": {
      "type": "string",
      "defaultValue": "10.0.0.0/24",
      "metadata": {
        "description": "Enter subnet address prefix."
      }
    },
    "skuName": {
      "type": "string",
      "defaultValue": "GP_Gen5",
      "allowedValues": [
        "GP_Gen5",
        "BC_Gen5"
      ],
      "metadata": {
        "description": "Enter sku name."
      }
    },
    "vCores": {
      "type": "int",
      "defaultValue": 16,
      "allowedValues": [
        4,
        8,
        16,
        24,
        32,
        40,
        64,
        80
      ],
      "metadata": {
        "description": "Enter number of vCores."
      }
    },
    "storageSizeInGB": {
      "type": "int",
      "defaultValue": 256,
      "maxValue": 8192,
      "minValue": 32,
      "metadata": {
        "description": "Enter storage size."
      }
    },
    "licenseType": {
      "type": "string",
      "defaultValue": "LicenseIncluded",
      "allowedValues": [
        "BasePrice",
        "LicenseIncluded"
      ],
      "metadata": {
        "description": "Enter license type."
      }
    }
  },
  "variables": {
    "networkSecurityGroupName": "[format('SQLMI-{0}-NSG', parameters('managedInstanceName'))]",
    "routeTableName": "[format('SQLMI-{0}-Route-Table', parameters('managedInstanceName'))]"
  },
  "resources": [
    {
      "type": "Microsoft.Network/networkSecurityGroups",
      "apiVersion": "2021-08-01",
      "name": "[variables('networkSecurityGroupName')]",
      "location": "[parameters('location')]",
      "properties": {
        "securityRules": [
          {
            "name": "allow_tds_inbound",
            "properties": {
              "description": "Allow access to data",
              "protocol": "Tcp",
              "sourcePortRange": "*",
              "destinationPortRange": "1433",
              "sourceAddressPrefix": "VirtualNetwork",
              "destinationAddressPrefix": "*",
              "access": "Allow",
              "priority": 1000,
              "direction": "Inbound"
            }
          },
          {
            "name": "allow_redirect_inbound",
            "properties": {
              "description": "Allow inbound redirect traffic to Managed Instance inside the virtual network",
              "protocol": "Tcp",
              "sourcePortRange": "*",
              "destinationPortRange": "11000-11999",
              "sourceAddressPrefix": "VirtualNetwork",
              "destinationAddressPrefix": "*",
              "access": "Allow",
              "priority": 1100,
              "direction": "Inbound"
            }
          },
          {
            "name": "deny_all_inbound",
            "properties": {
              "description": "Deny all other inbound traffic",
              "protocol": "*",
              "sourcePortRange": "*",
              "destinationPortRange": "*",
              "sourceAddressPrefix": "*",
              "destinationAddressPrefix": "*",
              "access": "Deny",
              "priority": 4096,
              "direction": "Inbound"
            }
          },
          {
            "name": "deny_all_outbound",
            "properties": {
              "description": "Deny all other outbound traffic",
              "protocol": "*",
              "sourcePortRange": "*",
              "destinationPortRange": "*",
              "sourceAddressPrefix": "*",
              "destinationAddressPrefix": "*",
              "access": "Deny",
              "priority": 4096,
              "direction": "Outbound"
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Network/routeTables",
      "apiVersion": "2021-08-01",
      "name": "[variables('routeTableName')]",
      "location": "[parameters('location')]",
      "properties": {
        "disableBgpRoutePropagation": false
      }
    },
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2021-08-01",
      "name": "[parameters('virtualNetworkName')]",
      "location": "[parameters('location')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[parameters('addressPrefix')]"
          ]
        },
        "subnets": [
          {
            "name": "[parameters('subnetName')]",
            "properties": {
              "addressPrefix": "[parameters('subnetPrefix')]",
              "routeTable": {
                "id": "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]"
              },
              "networkSecurityGroup": {
                "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
              },
              "delegations": [
                {
                  "name": "managedInstanceDelegation",
                  "properties": {
                    "serviceName": "Microsoft.Sql/managedInstances"
                  }
                }
              ]
            }
          }
        ]
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]",
        "[resourceId('Microsoft.Network/routeTables', variables('routeTableName'))]"
      ]
    },
    {
      "type": "Microsoft.Sql/managedInstances",
      "apiVersion": "2021-11-01-preview",
      "name": "[parameters('managedInstanceName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('skuName')]"
      },
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "administratorLogin": "[parameters('administratorLogin')]",
        "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
        "subnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]",
        "storageSizeInGB": "[parameters('storageSizeInGB')]",
        "vCores": "[parameters('vCores')]",
        "licenseType": "[parameters('licenseType')]"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]"
      ]
    }
  ]
}

テンプレートでは、次のリソースが定義されています。

その他のテンプレート サンプルについては、「Azure クイック スタート テンプレート」を参照してください。

テンプレートのデプロイ

次の PowerShell コード ブロックから [使ってみる] を選択して Azure Cloud Shell を開きます。

重要

マネージト インスタンスのデプロイは、実行時間の長い操作です。 サブネットへの最初のインスタンスのデプロイは、通常、既存のマネージド インスタンスが含まれるサブネットへのデプロイよりもはるかに長い時間がかかります。 平均的なプロビジョニング時間については、SQL Managed Instance の管理操作に関するセクションを参照してください。

$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names"
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
$templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.sql/sqlmi-new-vnet/azuredeploy.json"

$resourceGroupName = "${projectName}rg"

New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri

Read-Host -Prompt "Press [ENTER] to continue ..."

デプロイされているリソースを確認する

Azure portal にアクセスし、選択したリソース グループにマネージド インスタンスがあることを確認します。 マネージド インスタンスの作成には時間がかかる場合があるため、リソース グループの [概要] ページで [デプロイ] リンクを確認する必要がある場合があります。

  • Azure 仮想マシンから SQL マネージド インスタンスに接続する方法を説明するクイック スタートについては、Azure 仮想マシン接続の構成に関するページを参照してください。
  • ポイント対サイト接続を使用してオンプレミスのクライアント コンピューターから SQL マネージド インスタンスに接続する方法を説明するクイック スタートについては、ポイント対サイト接続の構成に関するページを参照してください。

リソースをクリーンアップする

次の手順に進む場合はマネージド インスタンスを保持しますが、追加のチュートリアルを完了した後でマネージド インスタンスと関連リソースを削除してください。 マネージド インスタンスを削除した後は、マネージド インスタンスの削除後のサブネットの削除に関するページを参照してください。

リソース グループを削除するには:

$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
Remove-AzResourceGroup -Name $resourceGroupName

次のステップ