クイックスタート: ARM テンプレートを使用して Azure Spring Apps をプロビジョニングする

注意

Azure Spring Apps は、Azure Spring Cloud サービスの新しい名前です。 サービスの名前は新しくなりましたが、スクリーンショット、ビデオ、図などの資産の更新に取り組んでいる間、場所によってはしばらく古い名前が表示されます。

この記事の適用対象:❌ Basic ✔️ Standard ✔️ Enterprise

このクイックスタートでは、Azure Resource Manager テンプレート (ARM テンプレート) を使用して、既存の仮想ネットワークに Azure Spring Apps クラスターをデプロイする方法について説明します。

Azure Spring Apps では、コードを変更せずに、Spring アプリケーションを Azure に簡単にデプロイできます。 Spring アプリケーションのインフラストラクチャはこのサービスによって管理されるため、開発者はコードに専念できます。 Azure Spring Apps では、包括的な監視と診断、構成管理、サービス検出、CI/CD 統合、ブルー/グリーン デプロイなどを使用して、ライフサイクルを管理できます。

Enterprise デプロイ プランには、次の Tanzu コンポーネントが含まれます。

  • ビルド サービス
  • アプリケーション構成サービス
  • サービス レジストリ
  • Spring Cloud Gateway
  • API ポータル
  • アプリケーション アクセラレータ
  • Application Live View

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

前提条件

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

  • Azure Spring Apps クラスター用の 2 つの専用サブネット (1 つはサービス ランタイム用、もう 1 つは Spring アプリケーション用)。 サブネットと仮想ネットワークの要件については、「仮想ネットワークに Azure Spring Apps をデプロイする」の「仮想ネットワークの要件」セクションを参照してください。

  • Azure Spring Apps の診断設定用の既存の Log Analytics ワークスペースと、ワークスペースベースの Application Insights リソース。 詳細については、「診断設定でログとメトリックを分析する」と「Azure Spring Apps での Application Insights Java In-Process Agent」を参照してください。

  • Azure Spring Apps クラスターに使用するために指定した 3 つの内部クラスレス ドメイン間ルーティング (CIDR) の範囲 (それぞれ少なくとも /16)。 これらの CIDR の範囲は直接ルーティング可能ではなく、Azure Spring Apps クラスターによって内部的にのみ使用されます。 クラスターは、内部 Azure Spring Apps の CIDR 範囲に 169.254.0.0/16172.30.0.0/16172.31.0.0/16192.0.2.0/24 を使用することはできません。 また、クラスターは、クラスターの仮想ネットワーク アドレス範囲に含まれる IP 範囲を使用することもできません。

  • 仮想ネットワークに付与されたサービスのアクセス許可。 仮想ネットワーク上の専用かつ動的なサービス プリンシパルにさらに高度なデプロイやメンテナンスの権限を付与するには、Azure Spring Apps リソース プロバイダーに仮想ネットワークの所有者としてのアクセス許可が必要です。 手順と詳細については、「仮想ネットワークに Azure Spring Apps をデプロイする」の「仮想ネットワークにサービス アクセス許可を付与する」セクションを参照してください。

  • Azure Firewall またはネットワーク仮想アプライアンス (NVA) を使用している場合は、次の前提条件も満たす必要があります。

  • ターゲット サブスクリプションで初めて Azure Spring Apps Enterprise プラン インスタンスをデプロイする場合は、「Azure Marketplace の Enterprise プラン」の「要件」セクションを参照してください。

テンプレートを確認する

このクイックスタートで使用されているテンプレートは、「Azure Spring Apps の参照アーキテクチャ」のものです。

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "springCloudInstanceName": {
            "type": "string",
            "metadata": {
                "description": "The instance name of the Azure Spring Cloud resource"
            }
        },
        "appInsightsName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Application Insights instance for Azure Spring Cloud"
            }
        },
        "laWorkspaceResourceId": {
            "type": "string",
            "metadata": {
                "description": "The resource ID of the existing Log Analytics workspace. This will be used for both diagnostics logs and Application Insights"
            }
        },
        "springCloudAppSubnetID": {
            "type": "string",
            "metadata": {
                "description": "The resourceID of the Azure Spring Cloud App Subnet"
            }
        },
        "springCloudRuntimeSubnetID": {
            "type": "string",
            "metadata": {
                "description": "The resourceID of the Azure Spring Cloud Runtime Subnet"
            }
        },
        "springCloudServiceCidrs": {
            "type": "string",
            "defaultValue": "10.0.0.0/16,10.2.0.0/16,10.3.0.1/16",
            "metadata": {
                "description": "Comma-separated list of IP address ranges in CIDR format. The IP ranges are reserved to host underlying Azure Spring Cloud infrastructure, which should be 3 at least /16 unused IP ranges, must not overlap with any Subnet IP ranges"
            }
        },        
        "tags": {
            "type": "object",
            "metadata": {
                "description": "The tags that will be associated to the Resources"
            },
            "defaultValue": {
                "environment": "lab"
            }
        }
    },
    "variables": {
        "location": "[resourceGroup().location]"                    
    },
    "resources": [
        {
            "type": "Microsoft.Insights/components",
            "name": "[parameters('appInsightsName')]",
            "apiVersion": "2020-02-02",
            "location": "[variables('location')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "Application_Type": "web",
                "ApplicationId": "[parameters('appInsightsName')]",
                "Flow_Type": "Bluefield",
                "Request_Source": "rest",
                "WorkspaceResourceId": "[parameters('laWorkspaceResourceId')]"
            }
        },
        {
            "apiVersion": "2022-03-01-preview",
            "name": "[parameters('springCloudInstanceName')]",
            "location": "[variables('location')]",
            "tags": "[parameters('tags')]",
            "dependsOn": [
                "[resourceId('Microsoft.Insights/components', parameters('appInsightsName'))]"
                
            ],
            "type": "Microsoft.AppPlatform/Spring",
            "sku": {
                "name": "E0",
                "tier": "Enterprise"
            },
            "properties": {
                "networkProfile": {
                    "serviceCidr": "[parameters('springCloudServiceCidrs')]",
                    "serviceRuntimeSubnetId": "[parameters('springCloudRuntimeSubnetID')]",
                    "appSubnetId": "[parameters('springCloudAppSubnetID')]"
                }
            },
            "resources": [
                {
                    "type": "serviceRegistries",
                    "name": "default",
                    "apiVersion": "2022-03-01-preview",
                    "location": "[variables('location')]",
                    "dependsOn": [
                        "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
                    ]
                },
                {
                    "type": "configurationServices",
                    "name": "default",
                    "apiVersion": "2022-03-01-preview",
                    "location": "[variables('location')]",
                    "dependsOn": [
                        "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
                    ]
                },
                {
                    "type": "gateways",
                    "name": "default",
                    "apiVersion": "2022-03-01-preview",
                    "location": "[variables('location')]",
                    "sku": {
                        "name": "E0",
                        "tier": "Enterprise",
                        "capacity": 2
                    },
                    "dependsOn": [
                        "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
                    ]
                },
                {
                    "type": "apiPortals",
                    "name": "default",
                    "apiVersion": "2022-03-01-preview",
                    "location": "[variables('location')]",
                    "sku": {
                        "name": "E0",
                        "tier": "Enterprise",
                        "capacity": 1
                    },
                    "properties": {
                        "gatewayIds": [
                            "[concat(resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName')), '/gateways/default')]"
                        ]
                    },
                    "dependsOn": [
                        "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
                    ]
                },
                {
                    "type": "Microsoft.AppPlatform/Spring/buildServices/agentPools",
                    "name": "[concat(parameters('springCloudInstanceName'), '/default/default')]",
                    "apiVersion": "2022-03-01-preview",
                    "location": "[variables('location')]",
                    "properties": {
                        "poolSize": {
                            "name": "S1"
                        }
                    },
                    "dependsOn": [
                        "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
                    ]
                }
            ]
        },
        {
            "apiVersion": "2022-03-01-preview",
            "name": "[concat(parameters('springCloudInstanceName'), '/default/default/default')]",
            "type": "Microsoft.AppPlatform/Spring/buildservices/builders/buildpackBindings",            
            "properties": {
                "bindingType": "ApplicationInsights",
                "launchProperties": {
                    "properties": {
                        "sampling_percentage": 10,
                        "connection_string": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').ConnectionString]"
                    }
                }
            },
            "dependsOn": [
                "[resourceId('Microsoft.AppPlatform/Spring', parameters('springCloudInstanceName'))]"
            ]
        },
        {
            "type": "Microsoft.AppPlatform/Spring/providers/diagnosticSettings",
            "name": "[concat(parameters('springCloudInstanceName'), '/Microsoft.Insights/monitoring')]",
            "dependsOn": [  
                "[resourceId('Microsoft.AppPlatform/Spring/', parameters('springCloudInstanceName'))]"       
            ],
            "apiVersion": "2017-05-01-preview",
            "properties": {
                "name": "monitoring",
                "workspaceId": "[parameters('laWorkspaceResourceId')]",
                "logs": [
                    {
                        "category": "ApplicationConsole",
                        "enabled": true,
                        "retentionPolicy": {
                            "days": 30,
                            "enabled": false
                        }
                    }
                ]
            }
        }
               
    ],
    "outputs": {
    }
}

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

テンプレートのデプロイ

テンプレートをデプロイするには、次の手順を使用します。

まず、次の画像を選び、Azure にサインインし、テンプレートを開きます。 このテンプレートにより、既存の仮想ネットワークに Azure Spring Apps インスタンスが作成され、既存の Azure Monitor Log Analytics ワークスペースにワークスペースベースの Application Insights インスタンスが作成されます。

次に、次のフィールドの値を入力します。

  • リソース グループ: [新規作成] を選択し、リソース グループの一意の名前を入力し、[OK] を選択します。
  • springCloudInstanceName: Azure Spring Apps リソースの名前を入力します。
  • appInsightsName: Azure Spring Apps の Application Insights インスタンスの名前を入力します。
  • laWorkspaceResourceId: 既存の Log Analytics ワークスペースのリソース ID を入力します (例: /subscriptions/<ご自分のサブスクリプション>/resourcegroups/<ご自分の Log Analytics リソース グループ>/providers/Microsoft.OperationalInsights/workspaces/<your Log Analytics workspace name>)。
  • springCloudAppSubnetID: Azure Spring Apps アプリケーション サブネットのリソース ID を入力します。
  • springCloudRuntimeSubnetID: Azure Spring Apps ランタイム サブネットのリソース ID を入力します。
  • springCloudServiceCidrs: IP アドレス範囲のコンマ区切りリスト (合計 3 つ) を CIDR 形式で入力します。 この IP 範囲は、基盤となる Azure Spring Apps インフラストラクチャをホストするために予約されています。 これらの 3 つの範囲は、少なくとも /16 の未使用の IP 範囲にするようにします。また、ネットワーク内で使用されているルーティング可能なサブネットの IP 範囲と重複してはなりません。
  • タグ: 任意のカスタム タグを入力します。

最後に、[確認および作成][作成] の順に選びます。

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

Azure portal を使用してデプロイされたリソースを確認するか、Azure CLI または Azure PowerShell スクリプトを使用してデプロイされたリソースを一覧表示することができます。

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

後続のクイック スタートおよびチュートリアルを引き続き実行する場合は、これらのリソースをそのまま残しておくことができます。 不要になったら、リソース グループを削除します。これにより、リソース グループ内のリソースが削除されます。 Azure CLI または Azure PowerShell を使用してリソース グループを削除するには、次のコマンドを使用します。

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

次の手順

このクイックスタートでは、ARM テンプレートを使用して Azure Spring Apps インスタンスを既存の仮想ネットワークにデプロイし、デプロイを検証しました。 Azure Spring Apps と Azure Resource Manager の詳細については、以下のリソースに進んでください。