mcpField
A
azure-openai-2025

azure-openai-2025

github.com/josiahsiegelクラウド・DevOps59164 回インストール19 週間前に更新
リポジトリ

azure-openai-2025 について

Azure OpenAI Service の導入・利用に関するチーム向けのリファレンススキルです。モデル、デプロイ、統合、セキュリティ、運用に加え、テキスト、推論、画像、動画、音声と Azure AI Foundry を扱います。

主な機能

  1. 012025 年のモデルと機能の概要
  2. 02Azure CLI によるデプロイ例
  3. 03Python SDK の利用パターン
  4. 04Azure AI Foundry との統合
  5. 05クォータと容量の管理
  6. 06セキュリティと監視の指針

活用シーン

  1. 01タスクに適したモデルの選択
  2. 02Azure OpenAI モデルのデプロイ
  3. 03プライベートエンドポイントとマネージド ID の設定
  4. 04利用状況の監視と容量管理

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill azure-openai-2025

インストール後、Claude Code で/azure-openai-2025を入力して読み込まれたか確認します。

同梱ファイルreferences/cost-monitoring.md

詳細

Azure OpenAI Service - 2025 モデルと機能

GPT-5、GPT-4.1、推論モデル、Azure AI Foundry との統合など、最新の 2025 年モデルを網羅した Azure OpenAI Service の完全なナレッジベースです。

概要

Azure OpenAI Service は、エンタープライズレベルのセキュリティ、コンプライアンス、リージョンでの利用可能性を備えた、OpenAI の最も高性能なモデルへの REST API アクセスを提供します。

最新モデル(2025 年)

GPT-5 シリーズ(2025 年 8 月に GA)

登録が必要なモデル:

  • gpt-5-pro:最高レベルの性能。複雑な推論に対応
  • gpt-5:性能とコストのバランスに優れています
  • gpt-5-codex:コード生成に最適化されています

登録不要:

  • gpt-5-mini:より高速で、より手頃な価格
  • gpt-5-nano:単純なタスク向けの超高速モデル
  • gpt-5-chat:会話での利用に最適化されています
GPT-4.1 シリーズ
  • gpt-4.1:100 万トークンのコンテキストウィンドウ
  • gpt-4.1-mini:100 万トークンのコンテキストに対応した効率的なバージョン
  • gpt-4.1-nano:最速のバリアント

主な改善点:

  • 1,000,000 トークンのコンテキスト(GPT-4 Turbo の 128K と比較)
  • 指示への追従性の向上
  • ハルシネーションの低減
  • 多言語サポートの改善
推論モデル

o4-mini:軽量な推論モデル

  • 推論が高速
  • 低コスト
  • 構造化された推論タスクに適しています

o3:高度な推論モデル

  • 複雑な問題解決
  • 数学的推論
  • 科学的分析

o1:初代の推論モデル

  • 汎用的な推論
  • 段階的な説明

o1-mini:効率的な推論

  • コストと性能のバランスに優れています
画像生成

GPT-image-1 (2025-04-15)

  • DALL-E 3 の後継
  • 画像品質の向上
  • プロンプト理解の改善
  • 安全性フィルターの改善
動画生成

Sora (2025-05-02)

  • テキストから動画を生成
  • リアルなシーンや想像上のシーンに対応
  • 最大 60 秒の動画
  • 複数のカメラアングルとスタイル
音声モデル

gpt-4o-transcribe:GPT-4o を活用した音声テキスト変換

  • 高精度な文字起こし
  • 複数の言語に対応
  • 話者ダイアライゼーション

gpt-4o-mini-transcribe:より高速で、より手頃な価格の文字起こし

  • 十分な精度
  • 低レイテンシ
  • 優れたコスト効率

Azure OpenAI のデプロイ

Azure OpenAI リソースの作成
# Create OpenAI account
az cognitiveservices account create \
  --name myopenai \
  --resource-group MyRG \
  --kind OpenAI \
  --sku S0 \
  --location eastus \
  --custom-domain myopenai \
  --public-network-access Disabled \
  --identity-type SystemAssigned

# Get endpoint and key
az cognitiveservices account show \
  --name myopenai \
  --resource-group MyRG \
  --query "properties.endpoint" \
  --output tsv

az cognitiveservices account keys list \
  --name myopenai \
  --resource-group MyRG \
  --query "key1" \
  --output tsv
GPT-5 モデルのデプロイ
# Deploy gpt-5
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name gpt-5 \
  --model-name gpt-5 \
  --model-version latest \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 100 \
  --scale-type Standard

# Deploy gpt-5-pro (requires registration)
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name gpt-5-pro \
  --model-name gpt-5-pro \
  --model-version latest \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 50
推論モデルのデプロイ
# Deploy o3 reasoning model
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name o3-reasoning \
  --model-name o3 \
  --model-version latest \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 50

# Deploy o4-mini
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name o4-mini \
  --model-name o4-mini \
  --model-version latest \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 100
100 万トークンのコンテキストを備えた GPT-4.1 のデプロイ
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name gpt-4-1 \
  --model-name gpt-4.1 \
  --model-version latest \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 100
画像生成モデルのデプロイ
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name image-gen \
  --model-name gpt-image-1 \
  --model-version 2025-04-15 \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 10
Sora 動画生成のデプロイ
az cognitiveservices account deployment create \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name sora \
  --model-name sora \
  --model-version 2025-05-02 \
  --model-format OpenAI \
  --sku-name Standard \
  --sku-capacity 5

Azure OpenAI モデルの使用

Python SDK(GPT-5)
from openai import AzureOpenAI
import os

# Initialize client
client = AzureOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    api_version="2025-02-01-preview",
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)

# GPT-5 completion
response = client.chat.completions.create(
    model="gpt-5",  # deployment name
    messages=[
        {"role": "system", "content": "You are a helpful AI assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    max_tokens=1000,
    temperature=0.7,
    top_p=0.95
)

print(response.choices[0].message.content)
Python SDK(o3 推論モデル)
# o3 reasoning with chain-of-thought
response = client.chat.completions.create(
    model="o3-reasoning",
    messages=[
        {"role": "system", "content": "You are an expert problem solver. Show your reasoning step-by-step."},
        {"role": "user", "content": "If a train travels 120 km in 2 hours, then speeds up to travel 180 km in the next 2 hours, what is the average speed for the entire journey?"}
    ],
    max_tokens=2000,
    temperature=0.2  # Lower temperature for reasoning tasks
)

print(response.choices[0].message.content)
Python SDK(100 万トークンのコンテキストを備えた GPT-4.1)
# Read a large document
with open('large_document.txt', 'r') as f:
    document = f.read()

# GPT-4.1 can handle up to 1M tokens
response = client.chat.completions.create(
    model="gpt-4-1",
    messages=[
        {"role": "system", "content": "You are a document analysis expert."},
        {"role": "user", "content": f"Analyze this document and provide key insights:\n\n{document}"}
    ],
    max_tokens=4000
)

print(response.choices[0].message.content)
画像生成(GPT-image-1)
# Generate image with DALL-E 3 successor
response = client.images.generate(
    model="image-gen",
    prompt="A futuristic city with flying cars and vertical gardens, cyberpunk style, highly detailed, 4K",
    size="1024x1024",
    quality="hd",
    n=1
)

image_url = response.data[0].url
print(f"Generated image: {image_url}")
動画生成(Sora)
# Generate video with Sora
response = client.videos.generate(
    model="sora",
    prompt="A serene lakeside at sunset with birds flying overhead and gentle waves on the shore",
    duration=10,  # seconds
    resolution="1080p",
    fps=30
)

video_url = response.data[0].url
print(f"Generated video: {video_url}")
音声の文字起こし
# Transcribe audio file
audio_file = open("meeting_recording.mp3", "rb")

response = client.audio.transcriptions.create(
    model="gpt-4o-transcribe",
    file=audio_file,
    language="en",
    response_format="verbose_json"
)

print(f"Transcription: {response.text}")
print(f"Duration: {response.duration}s")

# Speaker diarization
for segment in response.segments:
    print(f"[{segment.start}s - {segment.end}s] {segment.text}")

Azure AI Foundry との統合

モデルルーター(モデルの自動選択)
from azure.ai.foundry import ModelRouter

# Initialize model router
router = ModelRouter(
    endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    credential=os.getenv("AZURE_OPENAI_API_KEY")
)

# Automatically select optimal model
response = router.complete(
    prompt="Analyze this complex scientific paper...",
    optimization_goals=["quality", "cost"],
    available_models=["gpt-5", "gpt-5-mini", "gpt-4-1"]
)

print(f"Selected model: {response.model_used}")
print(f"Response: {response.content}")
print(f"Cost: ${response.cost}")

メリット:

  • プロンプトの複雑さに基づいてモデルを自動選択
  • 品質とコストのバランスを調整
  • 品質を維持しながら、コストを最大 40% 削減
エージェント型検索(Azure AI Search との統合)
from azure.search.documents import SearchClient
from azure.core.credentials import AzureKeyCredential

# Initialize search client
search_client = SearchClient(
    endpoint=os.getenv("SEARCH_ENDPOINT"),
    index_name="documents",
    credential=AzureKeyCredential(os.getenv("SEARCH_KEY"))
)

# Agentic retrieval with Azure OpenAI
response = client.chat.completions.create(
    model="gpt-5",
    messages=[
        {"role": "system", "content": "You have access to a document search system."},
        {"role": "user", "content": "What are the company's revenue projections for Q3?"}
    ],
    tools=[{
        "type": "function",
        "function": {
            "name": "search_documents",
            "description": "Search company documents",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {"type": "string", "description": "Search query"}
                },
                "required": ["query"]
            }
        }
    }],
    tool_choice="auto"
)

# Process tool calls
if response.choices[0].message.tool_calls:
    for tool_call in response.choices[0].message.tool_calls:
        if tool_call.function.name == "search_documents":
            query = json.loads(tool_call.function.arguments)["query"]
            results = search_client.search(query)
            # Feed results back to model for final answer

改善点:

  • 複雑で複数の要素を含む質問で 40% の性能向上
  • クエリの自動分解
  • 関連性のランク付け
  • 引用の生成
Foundry の可観測性(プレビュー)
from azure.ai.foundry import FoundryObservability

# Enable observability
observability = FoundryObservability(
    workspace_id=os.getenv("AI_FOUNDRY_WORKSPACE_ID"),
    enable_tracing=True,
    enable_metrics=True
)

# Monitor agent execution
with observability.trace_agent("customer_support_agent") as trace:
    response = client.chat.completions.create(
        model="gpt-5",
        messages=messages
    )

    trace.log_tool_call("search_kb", {"query": "refund policy"})
    trace.log_reasoning_step("Retrieved refund policy document")
    trace.log_token_usage(response.usage.total_tokens)

# View in Azure AI Foundry portal:
# - End-to-end trace logs
# - Reasoning steps and tool calls
# - Performance metrics
# - Cost analysis

容量とクォータの管理

クォータの確認
# List deployments with usage
az cognitiveservices account deployment list \
  --resource-group MyRG \
  --name myopenai \
  --output table

# Check usage metrics
az monitor metrics list \
  --resource $(az cognitiveservices account show -g MyRG -n myopenai --query id -o tsv) \
  --metric "TokenTransaction" \
  --start-time 2025-01-01T00:00:00Z \
  --end-time 2025-01-31T23:59:59Z \
  --interval PT1H \
  --aggregation Total
容量の更新
# Scale up deployment capacity
az cognitiveservices account deployment update \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name gpt-5 \
  --sku-capacity 200

# Scale down during off-peak
az cognitiveservices account deployment update \
  --resource-group MyRG \
  --name myopenai \
  --deployment-name gpt-5 \
  --sku-capacity 50
クォータの増加をリクエスト
  1. Azure Portal → Azure OpenAI リソースに移動します
  2. 「Quotas」ブレードを開きます
  3. モデルとリージョンを選択します
  4. 「Request quota increase」をクリックします
  5. 理由と目標容量を入力します

セキュリティとネットワーク

プライベートエンドポイント
# Create private endpoint
az network private-endpoint create \
  --name openai-private-endpoint \
  --resource-group MyRG \
  --vnet-name MyVNet \
  --subnet PrivateEndpointSubnet \
  --private-connection-resource-id $(az cognitiveservices account show -g MyRG -n myopenai --query id -o tsv) \
  --group-id account \
  --connection-name openai-connection

# Create private DNS zone
az network private-dns zone create \
  --resource-group MyRG \
  --name privatelink.openai.azure.com

# Link to VNet
az network private-dns link vnet create \
  --resource-group MyRG \
  --zone-name privatelink.openai.azure.com \
  --name openai-dns-link \
  --virtual-network MyVNet \
  --registration-enabled false

# Create DNS zone group
az network private-endpoint dns-zone-group create \
  --resource-group MyRG \
  --endpoint-name openai-private-endpoint \
  --name default \
  --private-dns-zone privatelink.openai.azure.com \
  --zone-name privatelink.openai.azure.com
マネージド ID によるアクセス
# Enable system-assigned identity
az cognitiveservices account identity assign \
  --name myopenai \
  --resource-group MyRG

# Grant role to managed identity
PRINCIPAL_ID=$(az cognitiveservices account show -g MyRG -n myopenai --query identity.principalId -o tsv)

az role assignment create \
  --assignee $PRINCIPAL_ID \
  --role "Cognitive Services OpenAI User" \
  --scope /subscriptions/<sub-id>/resourceGroups/MyRG
コンテンツフィルタリング
# Configure content filtering
az cognitiveservices account update \
  --name myopenai \
  --resource-group MyRG \
  --set properties.customContentFilter='{
    "hate": {"severity": "medium", "enabled": true},
    "violence": {"severity": "medium", "enabled": true},
    "sexual": {"severity": "medium", "enabled": true},
    "selfHarm": {"severity": "high", "enabled": true}
  }'

コストの最適化、監視、アラート

Azure OpenAI のデプロイにおける詳細なコスト最適化戦略、トークン予算の設定、クォータを考慮したルーティング、Azure Monitor のメトリック、Log Analytics のクエリ、アラートルールについては、references/cost-monitoring.md を参照してください。コストの管理や本番環境の可観測性の設定時に、このリファレンスを読み込んでください。

ベストプラクティス

✓ Model Router を使用してコストを自動的に最適化します ✓ 重複リクエストを減らすためにキャッシュを実装します ✓ トークン使用量を監視し、予算を設定します ✓ 本番環境のワークロードにはプライベートエンドポイントを使用します ✓ API キーの代わりにマネージド ID を有効化します ✓ 安全性を確保するためにコンテンツフィルタリングを構成します ✓ 実際の需要に基づいて容量を適正化します ✓ 監視にはFoundry Observability を使用します ✓ 指数バックオフを使用した再試行ロジックを実装します ✓ タスクの複雑さに応じて適切なモデルを選択します

参考資料

GPT-5 と推論モデルを備えた Azure OpenAI Service は、エンタープライズグレードの AI をアプリケーションにもたらします!

コメント