メインコンテンツまでスキップ

インフラアーキテクチャ

GenerativeXのインフラ構築により、Azure上に構築されるインフラストラクチャのアーキテクチャについて説明します。

概要

GenerativeXのインフラは、Azure Container Appsをベースとしたマルチテナント型のインフラストラクチャです。各テナント(企業・組織)ごとに独立したリソースグループとネットワーク空間が構築され、完全に分離された環境が提供されます。

マルチテナントアーキテクチャ

テナント分離

各テナントは以下のレベルで完全に分離されています:

  • リソースグループ: テナントごとに独立したリソースグループ(rg-{tenant}-{env}
  • ネットワーク: 独立したVirtual NetworkとSubnet
  • セキュリティ境界: ネットワークレベルでの完全分離
  • リソース: Container Apps、データベース、ストレージなどすべて独立

テンプレート

再利用可能なアプリケーション構成テンプレート:

  • frontend-backend: Next.js(フロントエンド)+ FastAPI(バックエンド)の分離型アーキテクチャ
  • monolith: Next.js(API Routes使用)のモノリシックアーキテクチャ

デプロイされるAzureリソース

frontend-backendテンプレートの場合

リソースグループ (rg-{tenant}-{env})
├── Container Apps Environment
│ ├── Frontend Container App (Next.js)
│ │ ├── External Ingress (HTTPS:443)
│ │ ├── FQDN: {app-name}.{region}.azurecontainerapps.io
│ │ └── Environment Variables
│ └── Backend Container App (FastAPI)
│ ├── External Ingress with IP Restrictions (HTTPS:443)
│ ├── FQDN: {app-name}.{region}.azurecontainerapps.io
│ └── Environment Variables
├── Azure Database for MySQL Flexible Server
│ ├── Private Endpoint Only
│ ├── Port: 3306
│ └── Database: {database-name}
├── Virtual Network (VNet)
│ └── Subnet (Container Apps用)
├── Log Analytics Workspace
└── Application Insights

monolithテンプレートの場合

リソースグループ (rg-{tenant}-{env})
├── Container Apps Environment
│ └── Frontend Container App (Next.js with API Routes)
│ ├── External Ingress (HTTPS:443)
│ ├── FQDN: {app-name}.{region}.azurecontainerapps.io
│ └── Environment Variables
├── Azure Database for MySQL Flexible Server
│ ├── Private Endpoint Only
│ ├── Port: 3306
│ └── Database: {database-name}
├── Virtual Network (VNet)
│ └── Subnet (Container Apps用)
├── Log Analytics Workspace
└── Application Insights

オプションで追加可能なリソース

  • Azure Cache for Redis: キャッシュ、セッション管理
  • Storage Account: ファイルストレージ、Blobストレージ
  • Custom Domain: カスタムドメイン設定

ネットワークアーキテクチャ

基本原則

  1. 最小権限の原則: 各コンポーネントは必要最小限のネットワークアクセスのみを持つ
  2. インターネット露出の最小化: バックエンドはIP制限で保護
  3. 内部通信の暗号化: コンポーネント間の通信は暗号化される
  4. 分離原則: テナントごとに独立したネットワーク空間を持つ

ネットワークトポロジー

全体構成図

┌─────────────────────────────────────────────────────────────────┐
│ Internet │
└────────────────────────────┬────────────────────────────────────┘

│ HTTPS (443)

┌────────▼────────┐
│ Azure CDN │ (Optional)
│ /Front Door │
└────────┬────────┘


┌──────────────────┴──────────────────┐
│ │
┌─────────▼─────────┐ ┌───────────▼──────────┐
│ Frontend │ │ Frontend │
│ Container App │ │ Container App │
│ (Public) │ │ (Monolith) │
│ │ │ (Public) │
│ - Port: 443 │ │ - Port: 443 │
│ - External │ │ - External │
│ Ingress │ │ Ingress │
└─────────┬─────────┘ └───────────┬──────────┘
│ │
│ Internal Network │ Internal
│ (VNet Integrated) │ (API Routes)
│ │
┌─────────▼─────────┐ ┌───────────▼──────────┐
│ Backend │ │ MySQL │
│ Container App │ │ Flexible Server │
│ (IP Restricted) │ │ (Private) │
│ │ │ │
│ - Port: 8000 │ │ - Port: 3306 │
│ - External │ │ - Private Endpoint │
│ Ingress │ │ │
│ with IP │ └──────────────────────┘
│ Restrictions │
└─────────┬─────────┘

│ Private

┌─────────▼─────────┐
│ MySQL │
│ Flexible Server │
│ (Private) │
│ │
│ - Port: 3306 │
│ - Private │
│ Endpoint │
└───────────────────┘

Container Apps Environment

すべてのContainer Appsは同一のContainer Apps Environment内にデプロイされます:

┌──────────────────────────────────────────────────────────────┐
│ Container Apps Environment │
│ (Internal VNet Integration) │
│ │
│ ┌─────────────────┐ ┌──────────────────┐ │
│ │ Frontend │ │ Backend │ │
│ │ Container App │────────▶│ Container App │ │
│ │ (External) │ │ (IP Restricted) │ │
│ └─────────────────┘ └──────────────────┘ │
│ │ │ │
│ │ │ │
│ └─────────────┬───────────────┘ │
│ │ │
│ │ Private Connection │
│ │ │
│ ┌─────────────▼───────────────┐ │
│ │ Azure Database for MySQL │ │
│ │ Flexible Server (Private) │ │
│ └─────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘

テンプレート別アーキテクチャ

1. frontend-backendテンプレート

アーキテクチャ: フロントエンドとバックエンドを分離した2層構成

ネットワーク構成

┌─────────────────────────────────────────────────────────────┐
│ Resource Group: rg-{tenant}-{env} │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Container Apps Environment │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────────┐ │ │
│ │ │ Frontend Container App │ │ │
│ │ │ │ │ │
│ │ │ Ingress: External │ │ │
│ │ │ Target Port: 3000 │ │ │
│ │ │ Traffic: 100% HTTPS │ │ │
│ │ │ FQDN: {app-name}.{region}.azurecontainerapps.io │ │ │
│ │ │ │ │ │
│ │ │ Environment Variables: │ │ │
│ │ │ - NEXT_PUBLIC_API_URL (Backend URL) │ │ │
│ │ └──────────────┬───────────────────────────────────┘ │ │
│ │ │ Internal Network │ │
│ │ │ (Service Discovery) │ │
│ │ ┌──────────────▼───────────────────────────────────┐ │ │
│ │ │ Backend Container App │ │ │
│ │ │ │ │ │
│ │ │ Ingress: External (with IP Restriction) │ │ │
│ │ │ Target Port: 8000 │ │ │
│ │ │ Accessible from Allowed IPs Only │ │ │
│ │ │ FQDN: {app-name}.{region}.azurecontainerapps.io │ │ │
│ │ │ │ │ │
│ │ │ IP Security Restrictions: │ │ │
│ │ │ - Configurable IP ranges (CIDR notation) │ │ │
│ │ │ │ │ │
│ │ │ Environment Variables: │ │ │
│ │ │ - DATABASE_HOST (MySQL Private Endpoint) │ │ │
│ │ └──────────────┬───────────────────────────────────┘ │ │
│ │ │ Private Network │ │
│ └─────────────────┼──────────────────────────────────────┘ │
│ │ │
│ ┌─────────────────▼──────────────────────────────────────┐ │
│ │ Azure Database for MySQL Flexible Server │ │
│ │ │ │
│ │ Network: Private Access Only │ │
│ │ Public Access: Disabled │ │
│ │ Private Endpoint: Enabled │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

アクセスフロー

  1. 外部からのアクセス:

    Internet User → Frontend (External Ingress) → Next.js App
  2. フロントエンドからバックエンドへのAPI呼び出し:

    Frontend → Backend (External Ingress with IP Restriction) → FastAPI App
    • バックエンドは外部からアクセス可能だが、IP制限で保護されている
    • 例: https://{backend-app-name}.{region}.azurecontainerapps.io
    • 許可されたIPレンジからのみアクセス可能
  3. バックエンドからデータベースへのアクセス:

    Backend → MySQL (Private Endpoint) → Database

セキュリティ特性

  • Frontend: インターネットからアクセス可能(External Ingress)
  • Backend: IP制限付きで外部公開(External Ingress with IP Restrictions)
    • 設定可能なIPレンジからのみアクセス許可
    • デフォルトでは全てのアクセスが拒否され、明示的に許可されたIPのみアクセス可能
    • 推奨設定: Container Apps Environment CIDR + オフィスIP
      • Japan East: 10.0.0.0/18
      • East US: 10.1.0.0/18
      • オフィスIP: 123.253.154.201/32, 150.195.212.125/32, 216.205.126.58/32
  • MySQL: プライベートエンドポイント経由のみアクセス可能

2. monolithテンプレート

アーキテクチャ: Next.jsのみでAPI Routesを使用した単一アプリケーション構成

ネットワーク構成

┌─────────────────────────────────────────────────────────────┐
│ Resource Group: rg-{tenant}-{env} │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Container Apps Environment │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────────┐ │ │
│ │ │ Frontend (Monolith) Container App │ │ │
│ │ │ │ │ │
│ │ │ Ingress: External │ │ │
│ │ │ Target Port: 3000 │ │ │
│ │ │ Traffic: 100% HTTPS │ │ │
│ │ │ FQDN: {app-name}.{region}.azurecontainerapps.io │ │ │
│ │ │ │ │ │
│ │ │ Features: │ │ │
│ │ │ - Next.js Pages/App Router │ │ │
│ │ │ - API Routes (/api/*) │ │ │
│ │ │ - Server-Side Rendering (SSR) │ │ │
│ │ │ │ │ │
│ │ │ Environment Variables: │ │ │
│ │ │ - DATABASE_HOST (MySQL Private Endpoint) │ │ │
│ │ └──────────────┬───────────────────────────────────┘ │ │
│ │ │ Private Network │ │
│ └─────────────────┼──────────────────────────────────────┘ │
│ │ │
│ ┌─────────────────▼──────────────────────────────────────┐ │
│ │ Azure Database for MySQL Flexible Server │ │
│ │ │ │
│ │ Network: Private Access Only │ │
│ │ Public Access: Disabled │ │
│ │ Private Endpoint: Enabled │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

アクセスフロー

  1. 外部からのアクセス(ページ):

    Internet User → Frontend (External Ingress) → Next.js Pages
  2. 外部からのAPIアクセス:

    Internet User → Frontend (External Ingress) → Next.js API Routes → Database
  3. 内部でのAPI呼び出し(SSR):

    Next.js Server → API Routes → Database

セキュリティ特性

  • Frontend/Backend統合: すべてが1つのコンテナで実行(External Ingress)
  • API Routes: /api/*パスでAPIを提供
  • MySQL: プライベートエンドポイント経由のみアクセス可能
  • ⚠️ API Routesはインターネットからアクセス可能(適切な認証・認可が必要)

テンプレート比較表

項目frontend-backendmonolith
構成2 Container Apps1 Container App
フロントエンド公開✅ External Ingress✅ External Ingress
バックエンド公開✅ IP制限付きExternal✅ API Routes (External)
バックエンド分離✅ 完全分離❌ 統合型
インターネット露出Frontend + Backend (IP制限)Frontend + API Routes
スケーリングFrontend/Backend 独立単一コンテナ
デプロイ複雑度
セキュリティ高(Backend IP制限)中(APIは公開)
推奨用途API重視、マイクロサービスシンプルなWebアプリ

オプションコンポーネント

Redis Cache

Redisを追加した場合のネットワーク構成:

┌─────────────────────────────────────────────┐
│ Backend Container App │
│ │ │
│ ├─────────────┐ │
│ │ │ │
│ ▼ ▼ │
│ ┌───────────┐ ┌──────────────┐ │
│ │ MySQL │ │ Azure Cache │ │
│ │ (Private)│ │ for Redis │ │
│ │ │ │ (Private) │ │
│ └───────────┘ └──────────────┘ │
└─────────────────────────────────────────────┘
  • RedisもPrivate Endpoint経由でのみアクセス可能
  • Backendからのみアクセス可能

Storage Account

Storage Accountを追加した場合:

┌─────────────────────────────────────────────┐
│ Backend Container App │
│ │ │
│ ├─────────────┐ │
│ │ │ │
│ ▼ ▼ │
│ ┌───────────┐ ┌──────────────┐ │
│ │ MySQL │ │ Storage │ │
│ │ (Private)│ │ Account │ │
│ │ │ │ (Private) │ │
│ └───────────┘ └──────────────┘ │
└─────────────────────────────────────────────┘
  • Blob、File、Table、Queueにアクセス可能
  • Private Endpoint経由でセキュアにアクセス

セキュリティアーキテクチャ

HTTPSの強制

すべてのContainer AppsはHTTPSを強制します:

  • 自動的に証明書が発行される
  • HTTPリクエストは自動的にHTTPSにリダイレクト

Container Apps Environmentによる分離

  • すべてのアプリは専用のContainer Apps Environment内で実行
  • 他のテナントとネットワークレベルで完全に分離

MySQLのプライベートアクセス

  • Public Accessは無効化
  • Private Endpoint経由でのみアクセス可能
  • Container Apps Environmentから安全にアクセス

環境変数の暗号化保存

  • すべての環境変数は暗号化してGitに保存
  • デプロイ時に復号化してContainer Appsに設定

IP制限(frontend-backendテンプレート)

  • Backend Container AppはIP制限で保護
  • デフォルトではContainer Apps Environment CIDR + オフィスIPのみ許可
  • カスタムIPレンジの設定が可能

共有リソース

Azure Container Registry

  • 全テナントで共有
  • 共通のACR (gxsharedacr.azurecr.io)
  • Managed Identityによる安全なアクセス

仮想ネットワーク

  • サブネット単位でテナント分離
  • IP制限によるバックエンドの保護(frontend-backendテンプレート)

Log Analytics

  • 統合監視・ログ管理
  • すべてのテナントのログを一元管理

データフロー

frontend-backendテンプレート

  1. ユーザーリクエスト:

    User → Internet → Frontend Container App (HTTPS:443)
  2. API呼び出し:

    Frontend → Backend Container App (HTTPS:443, IP制限)
  3. データベースアクセス:

    Backend → MySQL Flexible Server (Port:3306, Private Endpoint)

monolithテンプレート

  1. ユーザーリクエスト(ページ):

    User → Internet → Frontend Container App (HTTPS:443) → Next.js Pages
  2. API呼び出し:

    User → Internet → Frontend Container App (HTTPS:443) → Next.js API Routes → MySQL
  3. SSR時のデータベースアクセス:

    Next.js Server → MySQL Flexible Server (Port:3306, Private Endpoint)

スケーラビリティ

自動スケーリング

  • Container Appsは自動的にスケールアウト/スケールイン
  • CPU/メモリ使用率に基づいてレプリカ数を調整
  • 最小/最大レプリカ数の設定が可能

マルチテナント対応

  • テナントごとに独立したリソースグループ
  • ネットワークレベルでの完全分離
  • テナントごとに異なる設定を適用可能

監視とログ

Application Insights

  • アプリケーションのパフォーマンス監視
  • エラー追跡とアラート
  • リアルタイムメトリクス

Log Analytics

  • すべてのログの一元管理
  • Kustoクエリによるログ検索
  • カスタムダッシュボードの作成

関連ドキュメント