次の方法で共有


クイック スタート: 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 で開きます。

Azure にデプロイする

前提 条件

  • Azure サブスクリプション。 Azure サブスクリプションをお持ちでない場合は、無料アカウントを作成
  • 一般的なケースでは、ユーザーには、サブスクリプション スコープで SQL Managed Instance 共同作成者 ロールを割り当てる必要があります。
  • Azure SQL Managed Instance に既に委任されているサブネットでプロビジョニングする場合、ユーザーに必要なのは、サブスクリプション スコープで割り当てられた Microsoft.Sql/managedInstances/write アクセス許可のみです。

テンプレートを確認する

このクイック スタートで使用するテンプレートは、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 Managed Instance に接続する方法を示すクイック スタートについては、「Azure 仮想マシン接続を構成する」を参照してください。
  • ポイント対サイト接続を使用してオンプレミスのクライアント コンピューターから SQL Managed Instance に接続する方法を示すクイック スタートについては、「ポイント対サイト接続を構成する」を参照してください。

リソースのクリーンアップ

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

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

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

次の手順

Azure SQL Managed Instance に接続するように Azure VM を構成する