次の方法で共有


クイック スタート: Azure AI Content Understanding REST API を使用する

前提条件

開始するには、 アクティブな Azure サブスクリプションが必要です。 Azure アカウントがない場合は、無料で作成できます

  • Azure サブスクリプションを取得したら、Azure portal で Azure AI Foundry リソース を作成します。

    • このリソースは、ポータルの [AI Foundry>AI Foundry ] の下に表示されます。

      Azure portal の [AI Foundry リソース] ページのスクリーンショット。

このガイドでは、cURL コマンド ライン ツールを使用します。 インストールされていない場合は、開発環境に適したバージョンを ダウンロード できます。

事前構築済みアナライザーを使い始めましょう

アナライザーは、コンテンツの処理方法と抽出される分析情報を定義します。 一般的なユース ケース用 の事前構築済みアナライザー を提供しています。 事前構築済みのアナライザーは、特定のニーズやユース ケースに合わせてカスタマイズできます。 このクイック スタートでは、事前構築済みのドキュメント、画像、オーディオ、およびビデオ アナライザーを使用して、作業の開始に役立ちます。

分析用のファイルを送信する

次の cURL コマンドを実行する前に、HTTP 要求に次の変更を加えます。

  1. {endpoint}{key}を、Azure portal の Azure AI Foundry インスタンスの対応する値に置き換えます。
  2. {analyzerId}prebuilt-documentAnalyzerに置き換えます。 このアナライザーは、段落、セクション、テーブルなどのテキストとレイアウト要素をドキュメントから抽出します。
  3. {fileUrl}を、分析するファイルのパブリックにアクセス可能な URL (共有アクセス署名 (SAS) を使用した Azure Storage BLOB へのパスなど) に置き換えるか、サンプル URL https://github.com/Azure-Samples/azure-ai-content-understanding-python/raw/refs/heads/main/data/invoice.pdfを使用します。

POST 要求

curl -i -X POST "{endpoint}/contentunderstanding/analyzers/{analyzerId}:analyze?api-version=2025-05-01-preview" \
  -H "Ocp-Apim-Subscription-Key: {key}" \
  -H "Content-Type: application/json" \
  -d "{\"url\":\"{fileUrl}\"}"

POST 応答

応答には、非同期分析操作の結果を取得するために使用する resultIdを含む JSON 本文が含まれます。 さらに、 Operation-Location ヘッダーは、分析結果にアクセスするための直接 URL を提供します。

202 Accepted
Operation-Location: {endpoint}/contentunderstanding/analyzerResults/{resultId}?api-version=2024-12-01-preview
{
  "id": {resultId},
  "status": "Running",
  "result": {
    "analyzerId": {analyzerId},
    "apiVersion": "2025-05-01-preview",
    "createdAt": "YYYY-MM-DDTHH:MM:SSZ",
    "warnings": [],
    "contents": []
  }
}

分析結果を取得する

resultId応答からPOSTを使用し、分析の結果を取得します。

  1. {endpoint}{key}を、Azure portal Azure AI Foundry インスタンスのエンドポイントとキー値に置き換えます。
  2. {analyzerResultId}POST応答のidに置き換えるか、Operation-Location応答ヘッダーの完全な URL を使用します。

GET 要求

curl -i -X GET "GET {endpoint}/contentunderstanding/analyzerResults/{analyzerResultId}?api-version=2025-05-01-preview" \
  -H "Ocp-Apim-Subscription-Key: {key}"

GET 応答

200 (OK) JSON 応答には、操作の状態を示す status フィールドが含まれています。 操作が完了していない場合、status の値は Running または NotStartedです。 このような場合は、手動またはスクリプトを使用して、 GET 要求をもう一度送信する必要があります。 呼び出しの間隔は 1 秒以上あけてください。

{
  "id": {resultId},
  "status": "Succeeded",
  "result": {
    "analyzerId": "prebuilt-documentAnalyzer",
    "apiVersion": "2025-05-01-preview",
    "createdAt": "YYYY-MM-DDTHH:MM:SSZ",
    "warnings": [],
    "contents": [
      {
        "markdown": "CONTOSO LTD.\n\n\n# INVOICE\n\nContoso Headquarters\n123 456th St...",
        "fields": {
          "Summary": {
            "type": "string",
            "valueString": "This document is an invoice issued by Contoso Ltd. to Microsoft Corporation for services rendered during the period of 10/14/2019 to 11/14/2019..."
          }
        },
        "kind": "document",
        "startPageNumber": 1,
        "endPageNumber": 1,
        "unit": "inch",
        "pages": [
          {
            "pageNumber": 1,
            "angle": -0.0039,
            "width": 8.5,
            "height": 11,
            "spans": [ { "offset": 0, "length": 1650 } ],
            "words": [
              {
                "content": "CONTOSO",
                "span": { "offset": 0, "length": 7 },
                "confidence": 0.998,
                "source": "D(1,0.5739,0.6582,1.7446,0.6595,1.7434,0.8952,0.5729,0.8915)"
              }, ...
            ],
            "lines": [
              {
                "content": "CONTOSO LTD.",
                "source": "D(1,0.5734,0.6563,2.335,0.6601,2.3345,0.8933,0.5729,0.8895)",
                "span": { "offset": 0, "length": 12 }
              }, ...
            ]
          }
        ],
        "paragraphs": [
          {
            "content": "CONTOSO LTD.",
            "source": "D(1,0.5734,0.6563,2.335,0.6601,2.3345,0.8933,0.5729,0.8895)",
            "span": { "offset": 0, "length": 12 }
          },
          {
            "role": "title",
            "content": "INVOICE",
            "source": "D(1,7.0515,0.5614,8.0064,0.5628,8.006,0.791,7.0512,0.7897)",
            "span": { "offset": 15, "length": 9 }
          }, ...
        ],
        "sections": [
          {
            "span": { "offset": 0, "length": 1649 },
            "elements": [ "/sections/1", "/sections/2" ]
          }, ...
        ],
        "tables": [
          {
            "rowCount": 2,
            "columnCount": 6,
            "cells": [
              {
                "kind": "columnHeader",
                "rowIndex": 0,
                "columnIndex": 0,
                "rowSpan": 1,
                "columnSpan": 1,
                "content": "SALESPERSON",
                "source": "D(1,0.5389,4.5514,1.7505,4.5514,1.7505,4.8364,0.5389,4.8364)",
                "span": { "offset": 512, "length": 11 },
                "elements": [ "/paragraphs/19" ]
              }, ...
            ],
            "source": "D(1,0.4885,4.5543,8.0163,4.5539,8.015,5.1207,0.4879,5.1209)",
            "span": { "offset": 495, "length": 228 }
          }, ...
        ]
      }
    ]
  }
}

次のステップ

ユース ケース用の カスタム アナライザーの作成の 詳細について説明します。