安裝及執行表單辨識器容器Install and run Form Recognizer containers

Azure 表單辨識器會套用機器學習技術,以識別並從表單中解壓縮索引鍵/值組和資料表。Azure Form Recognizer applies machine learning technology to identify and extract key-value pairs and tables from forms. 它會將值和資料表專案與索引鍵/值配對產生關聯,然後輸出包含原始檔案中之關聯性的結構化資料。It associates values and table entries with the key-value pairs and then outputs structured data that includes the relationships in the original file.

若要降低複雜性並輕鬆地將自訂表單辨識器模型整合到您的工作流程自動化程式或其他應用程式中,您可以使用簡單的 REST API 來呼叫模型。To reduce complexity and easily integrate a custom Form Recognizer model into your workflow automation process or other application, you can call the model by using a simple REST API. 只需要五個表單檔(或一個空白表單和兩個填滿表單),因此您可以快速、精確地取得結果,並針對您的特定內容量身打造。Only five form documents (or one empty form and two filled-in forms) are needed, so you can get results quickly, accurately, and tailored to your specific content. 不需要大量的手動介入或廣泛的資料科學專業知識。No heavy manual intervention or extensive data science expertise is necessary. 而且它不需要資料標記或資料批註。And it doesn't require data labeling or data annotation.

函數Function 功能Features
表單辨識器Form Recognizer
  • 處理 PDF、PNG 和 JPG 檔案Processes PDF, PNG, and JPG files
  • 以相同版面配置的最少五種形式,訓練自訂模型Trains custom models with a minimum of five forms of the same layout
  • 解壓縮索引鍵/值組和資料表資訊Extracts key-value pairs and table information
  • 使用 Azure 認知服務電腦視覺 API 辨識文字功能,從表單內的影像偵測及解壓縮印刷文字Uses the Azure Cognitive Services Computer Vision API Recognize Text feature to detect and extract printed text from images inside forms
  • 不需要注釋或標籤Doesn't require annotation or labeling
  • 如果您沒有 Azure 訂用帳戶,請在開始前建立 免費帳戶If you don't have an Azure subscription, create a free account before you begin.

    必要條件Prerequisites

    使用表單辨識器容器之前,您必須符合下列必要條件:Before you use Form Recognizer containers, you must meet the following prerequisites:

    必要項Required 用途Purpose
    Docker 引擎Docker Engine 您必須在主機電腦上安裝 Docker 引擎。You need the Docker Engine installed on a host computer. Docker 提供可在 macOSWindowsLinux 上設定 Docker 環境的套件。Docker provides packages that configure the Docker environment on macOS, Windows, and Linux. 如需 Docker 和容器基本概念的入門,請參閱 Docker 概觀 (英文)。For a primer on Docker and container basics, see the Docker overview.

    Docker 必須設定為允許容器與 Azure 連線,以及傳送帳單資料至 Azure。Docker must be configured to allow the containers to connect with and send billing data to Azure.

    在 Windows 上,您也必須將 Docker 設定為支援 Linux 容器。On Windows, Docker must also be configured to support Linux containers.

    熟悉 DockerFamiliarity with Docker 您應該對 Docker 概念有基本的瞭解,例如登錄、存放庫、容器和容器映射,以及基本docker命令的知識。You should have a basic understanding of Docker concepts, such as registries, repositories, containers, and container images, and knowledge of basic docker commands.
    Azure CLIThe Azure CLI 在您的主機上安裝Azure CLIInstall the Azure CLI on your host.
    電腦視覺 API 資源Computer Vision API resource 若要處理掃描的檔和影像,您需要電腦視覺資源。To process scanned documents and images, you need a Computer Vision resource. 您可以將「辨識文字」功能當作 Azure 資源(REST API 或 SDK)或認知服務辨識文字容器來存取。You can access the Recognize Text feature as either an Azure resource (the REST API or SDK) or a cognitive-services-recognize-text container. 適用一般計費費用。The usual billing fees apply.

    同時傳入電腦視覺資源(Azure 雲端或認知服務容器)的 API 金鑰和端點。Pass in both the API key and endpoints for your Computer Vision resource (Azure cloud or Cognitive Services container). 使用此 API 金鑰和端點作為 {COMPUTER_VISION_API_KEY}{COMPUTER_VISION_ENDPOINT_URI}Use this API key and the endpoint as {COMPUTER_VISION_API_KEY} and {COMPUTER_VISION_ENDPOINT_URI}.

    如果您使用認知服務-辨識文字容器,請確定:If you use the cognitive-services-recognize-text container, make sure that:

    您的表單辨識器容器的電腦視覺金鑰是認知服務的電腦視覺docker run命令中所指定的金鑰。Your Computer Vision key for the Form Recognizer container is the key specified in the Computer Vision docker run command for the cognitive-services-recognize-text container.
    您的帳單端點是容器的端點( http://localhost:5000例如)。Your billing endpoint is the container's endpoint (for example, http://localhost:5000). 如果您同時在相同的主機上同時使用電腦視覺容器和表單辨識器容器,則無法使用預設通訊埠5000來啟動它們。If you use both the Computer Vision container and Form Recognizer container together on the same host, they can't both be started with the default port of 5000.
    表單辨識器資源Form Recognizer resource 若要使用這些容器,您必須具有:To use these containers, you must have:

    Azure表單辨識器資源,用來取得相關聯的 API 金鑰和端點 URI。An Azure Form Recognizer resource to get the associated API key and endpoint URI. 這兩個值都可在 Azure 入口網站表單辨識器總覽和 [金鑰] 頁面上取得,而這兩個值都是啟動容器的必要條件。Both values are available on the Azure portal Form Recognizer Overview and Keys pages, and both values are required to start the container.

    {FORM_RECOGNIZER_API_KEY} :[金鑰] 頁面上有兩個可用的資源金鑰之一{FORM_RECOGNIZER_API_KEY}: One of the two available resource keys on the Keys page

    {FORM_RECOGNIZER_ENDPOINT_URI} :[總覽] 頁面上所提供的端點{FORM_RECOGNIZER_ENDPOINT_URI}: The endpoint as provided on the Overview page

    正在搜集必要的參數Gathering required parameters

    所有必要的認知服務容器都有三個主要參數。There are three primary parameters for all Cognitive Services' containers that are required. 使用者授權合約(EULA)必須存在,且值為acceptThe end-user license agreement (EULA) must be present with a value of accept. 此外,也需要端點 URL 和 API 金鑰。Additionally, both an Endpoint URL and API Key are needed.

    端點 URI {COMPUTER_VISION_ENDPOINT_URI}{FORM_RECOGNIZER_ENDPOINT_URI}Endpoint URI {COMPUTER_VISION_ENDPOINT_URI} and {FORM_RECOGNIZER_ENDPOINT_URI}

    [端點URI] 值可在對應認知服務資源的 [Azure 入口網站總覽] 頁面上取得。The Endpoint URI value is available on the Azure portal Overview page of the corresponding Cognitive Service resource. 流覽至 [總覽] 頁面,將滑鼠停留在端點上Copy to clipboard圖示就會出現。Navigate to the Overview page, hover over the Endpoint, and a Copy to clipboard icon will appear. 視需要複製並使用。Copy and use where needed.

    收集端點 uri 以供稍後使用

    金鑰{COMPUTER_VISION_API_KEY}{FORM_RECOGNIZER_API_KEY}Keys {COMPUTER_VISION_API_KEY} and {FORM_RECOGNIZER_API_KEY}

    此金鑰用來啟動容器,並可在對應認知服務資源的 Azure 入口網站的 [金鑰] 頁面上取得。This key is used to start the container, and is available on the Azure portal's Keys page of the corresponding Cognitive Service resource. 流覽至 [金鑰] 頁面,然後按一下Copy to clipboard 圖示。Navigate to the Keys page, and click on the Copy to clipboard icon.

    取得兩個金鑰的其中一個供稍後使用

    重要

    這些訂用帳戶金鑰可用來存取您的認知服務 API。These subscription keys are used to access your Cognitive Service API. 請勿共用您的金鑰。Do not share your keys. 以安全的方式儲存它們,例如使用 Azure Key Vault。Store them securely, for example, using Azure Key Vault. 我們也建議您定期重新產生這些金鑰。We also recommend regenerating these keys regularly. 進行 API 呼叫時,只需要一個金鑰。Only one key is necessary to make an API call. 重新產生第一個金鑰時,您可以使用第二個金鑰繼續存取服務。When regenerating the first key, you can use the second key for continued access to the service.

    要求存取容器登錄Request access to the container registry

    您必須先完成並提交認知服務表單辨識器容器存取要求表單, 以要求容器的存取權。You must first complete and submit the Cognitive Services Form Recognizer Containers access request form to request access to the container. 這麼做也會讓您登入電腦視覺。Doing so also signs you up for Computer Vision. 您不需要另外註冊電腦視覺要求表單。You don't need to sign up for the Computer Vision request form separately.

    該表格需要有關您本身、您的公司,以及您將會使用該容器之使用者情節的資訊。The form requests information about you, your company, and the user scenario for which you'll use the container. 您已提交表單之後,Azure 認知服務小組會檢閱,以確保您符合私人容器登錄的存取權的準則。After you've submitted the form, the Azure Cognitive Services team reviews it to ensure that you meet the criteria for access to the private container registry.

    重要

    您必須使用與在表單中的 Microsoft 帳戶 (MSA) 或 Azure Active Directory (Azure AD) 帳戶相關聯的電子郵件地址。You must use an email address that's associated with either a Microsoft Account (MSA) or Azure Active Directory (Azure AD) account in the form.

    如果您的要求獲得核准,您會收到一封電子郵件,說明如何取得您的認證和存取私人容器登錄庫的指示。If your request is approved, you'll receive an email with instructions that describe how to obtain your credentials and access the private container registry.

    使用 Docker CLI 來驗證私人容器登錄Use the Docker CLI to authenticate the private container registry

    您可以向私人容器登錄的認知服務容器中任一種,但建議的方法,從命令列是使用Docker CLIYou can authenticate with the private container registry for Cognitive Services Containers in any of several ways, but the recommended method from the command line is to use the Docker CLI.

    使用docker login命令所示,在下列範例中,登入containerpreview.azurecr.io,認知服務容器的私用容器登錄。Use the docker login command, as shown in the following example, to log in to containerpreview.azurecr.io, the private container registry for Cognitive Services Containers. 取代 <使用者名稱> 的使用者名稱與 <密碼> 提供認證,您已收到的密碼Azure 認知服務小組。Replace <username> with the user name and <password> with the password that's provided in the credentials you received from the Azure Cognitive Services team.

    docker login containerpreview.azurecr.io -u <username> -p <password>
    

    如果您已受保護您的認證在文字檔中,您可以藉由串連該文字檔的內容cat命令,以docker login命令,如下列範例所示。If you've secured your credentials in a text file, you can concatenate the contents of that text file, by using the cat command, to the docker login command, as shown in the following example. 取代 <passwordFile> 使用的路徑和名稱的文字檔案,其中包含密碼和 <username> 的使用者名稱提供您的認證。Replace <passwordFile> with the path and name of the text file that contains the password and <username> with the user name that's provided in your credentials.

    cat <passwordFile> | docker login containerpreview.azurecr.io -u <username> --password-stdin
    

    主機電腦The host computer

    主機是可執行 Docker 容器的 x64 型電腦。The host is a x64-based computer that runs the Docker container. 它可以是您內部部署的電腦,或是在 Azure 中裝載服務的 Docker,例如:It can be a computer on your premises or a Docker hosting service in Azure, such as:

    容器的需求和建議Container requirements and recommendations

    下表說明每個表單辨識器容器所要配置的最低和建議的 CPU 核心和記憶體:The minimum and recommended CPU cores and memory to allocate for each Form Recognizer container are described in the following table:

    容器Container 最小值Minimum 建議Recommended
    表單辨識器Form Recognizer 2核心,4 GB 記憶體2 core, 4-GB memory 4核心,8 GB 記憶體4 core, 8-GB memory
    辨識文字Recognize Text 1個核心,8 GB 記憶體1 core, 8-GB memory 2個核心,8 GB 記憶體2 cores, 8-GB memory
    • 每個核心必須至少 2.6 GHz 或更快。Each core must be at least 2.6 gigahertz (GHz) or faster.
    • 核心和記憶體會對應至 --cpus--memory 設定,用來作為 docker run 命令的一部分。Core and memory correspond to the --cpus and --memory settings, which are used as part of the docker run command.

    注意

    最低和建議值是根據 Docker 限制,而是主機電腦資源。The minimum and recommended values are based on Docker limits and not the host machine resources.

    使用 docker pull 命令取得容器映射Get the container images with the docker pull command

    下列 container registry 提供表單辨識器辨識文字供應專案的容器映射:Container images for both the Form Recognizer and Recognize Text offerings are available in the following container registry:

    容器Container 完整的映射名稱Fully qualified image name
    表單辨識器Form Recognizer containerpreview.azurecr.io/microsoft/cognitive-services-form-recognizer:latest
    辨識文字Recognize Text containerpreview.azurecr.io/microsoft/cognitive-services-recognize-text:latest

    您需要這兩個容器,請注意,在本文外會詳細說明辨識器文字容器。You will need both containers, please note that the Recognizer Text container is detailed outside of this article.

    提示

    您可以使用 docker images (英文) 命令來列出已下載的容器映像。You can use the docker images command to list your downloaded container images. 例如,下列命令會列出每個已下載之容器映像的識別碼、存放庫和標籤,並將它格式化為表格:For example, the following command lists the ID, repository, and tag of each downloaded container image, formatted as a table:

    docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
    
    IMAGE ID         REPOSITORY                TAG
    <image-id>       <repository-path/name>    <tag-name>
    

    表單辨識器容器的 Docker PullDocker pull for the Form Recognizer container

    表單辨識器Form Recognizer

    若要取得表單辨識器容器,請使用下列命令:To get the Form Recognizer container, use the following command:

    docker pull containerpreview.azurecr.io/microsoft/cognitive-services-form-recognizer:latest
    

    辨識文字容器的 Docker PullDocker pull for the Recognize Text container

    辨識文字Recognize Text

    若要取得辨識文字容器,請使用下列命令:To get the Recognize Text container, use the following command:

    docker pull containerpreview.azurecr.io/microsoft/cognitive-services-recognize-text:latest
    

    如何使用容器How to use the container

    在容器位於主機電腦上之後,請使用下列程式來處理容器。After the container is on the host computer, use the following process to work with the container.

    1. 使用所需的計費設定執行容器Run the container, with the required billing settings. docker run 命令有相關範例可供參考。More examples of the docker run command are available.
    2. 查詢容器的預測端點Query the container's prediction endpoint.

    使用 docker run 命令執行容器Run the container by using the docker run command

    docker run 命令執行容器。Use the docker run command to run the container. 如需如何取得{COMPUTER_VISION_ENDPOINT_URI}{COMPUTER_VISION_API_KEY} {FORM_RECOGNIZER_ENDPOINT_URI}{FORM_RECOGNIZER_API_KEY}值的詳細資訊,請參閱收集必要的參數Refer to gathering required parameters for details on how to get the {COMPUTER_VISION_ENDPOINT_URI}, {COMPUTER_VISION_API_KEY}, {FORM_RECOGNIZER_ENDPOINT_URI} and {FORM_RECOGNIZER_API_KEY} values.

    命令的範例可供使用。docker runExamples of the docker run command are available.

    表單辨識器Form Recognizer

    docker run --rm -it -p 5000:5000 --memory 8g --cpus 2 \
    --mount type=bind,source=c:\input,target=/input  \
    --mount type=bind,source=c:\output,target=/output \
    containerpreview.azurecr.io/microsoft/cognitive-services-form-recognizer \
    Eula=accept \
    Billing={FORM_RECOGNIZER_ENDPOINT_URI} \
    ApiKey={FORM_RECOGNIZER_API_KEY} \
    FormRecognizer:ComputerVisionApiKey={COMPUTER_VISION_API_KEY} \
    FormRecognizer:ComputerVisionEndpointUri={COMPUTER_VISION_ENDPOINT_URI}
    

    此命令:This command:

    • 從容器映射執行表單辨識器容器。Runs a Form Recognizer container from the container image.
    • 配置2個 CPU 核心和 8 gb 的記憶體。Allocates 2 CPU cores and 8 gigabytes (GB) of memory.
    • 公開 TCP 埠5000,並為容器配置虛擬 TTY。Exposes TCP port 5000 and allocates a pseudo-TTY for the container.
    • 在容器結束之後自動將其移除。Automatically removes the container after it exits. 容器映像仍可在主機電腦上使用。The container image is still available on the host computer.
    • 將/input 和/output 磁片區掛接至容器。Mounts an /input and an /output volume to the container.

    在相同主機上執行多個容器Run multiple containers on the same host

    如果您打算使用公開的連接埠執行多個容器,請務必使用不同的公開連接埠來執行每個容器。If you intend to run multiple containers with exposed ports, make sure to run each container with a different exposed port. 例如,在連接埠 5000 上執行第一個容器,以及在連接埠 5001 上執行第二個容器。For example, run the first container on port 5000 and the second container on port 5001.

    您可以讓此容器和不同的 Azure 認知服務容器在主機上一起執行。You can have this container and a different Azure Cognitive Services container running on the HOST together. 您也可以針對相同的認知服務容器執行多個容器。You also can have multiple containers of the same Cognitive Services container running.

    以個別的 docker 執行命令執行個別的容器Run separate containers as separate docker run commands

    針對裝載在相同主機本機上的表單辨識器和文字辨識器組合,請使用下列兩個範例 Docker CLI 命令:For the Form Recognizer and Text Recognizer combination that's hosted locally on the same host, use the following two example Docker CLI commands:

    在連接埠 5000 上執行第一個容器。Run the first container on port 5000.

    docker run --rm -it -p 5000:5000 --memory 4g --cpus 1 \
    --mount type=bind,source=c:\input,target=/input  \
    --mount type=bind,source=c:\output,target=/output \
    containerpreview.azurecr.io/microsoft/cognitive-services-form-recognizer \
    Eula=accept \
    Billing={FORM_RECOGNIZER_ENDPOINT_URI} \
    ApiKey={FORM_RECOGNIZER_API_KEY}
    FormRecognizer:ComputerVisionApiKey={COMPUTER_VISION_API_KEY} \
    FormRecognizer:ComputerVisionEndpointUri={COMPUTER_VISION_ENDPOINT_URI}
    

    在連接埠 5001 上執行第二個容器。Run the second container on port 5001.

    docker run --rm -it -p 5001:5000 --memory 4g --cpus 1 \
    containerpreview.azurecr.io/microsoft/cognitive-services-recognize-text \
    Eula=accept \
    Billing={COMPUTER_VISION_ENDPOINT_URI} \
    ApiKey={COMPUTER_VISION_API_KEY}
    

    每個後續容器應該位於不同的連接埠。Each subsequent container should be on a different port.

    透過 Docker Compose 執行個別的容器Run separate containers with Docker Compose

    針對裝載在相同主機本機上的表單辨識器和文字辨識器組合,請參閱下列範例 Docker Compose YAML 檔案。For the Form Recognizer and Text Recognizer combination that's hosted locally on the same host, see the following example Docker Compose YAML file. formrecognizerocr 容器的文字辨識器 {COMPUTER_VISION_API_KEY} 必須相同。The Text Recognizer {COMPUTER_VISION_API_KEY} must be the same for both the formrecognizer and ocr containers. 只能在容器中使用, formrecognizer ocr因為容器會使用名稱和埠。 {COMPUTER_VISION_ENDPOINT_URI} ocrThe {COMPUTER_VISION_ENDPOINT_URI} is used only in the ocr container, because the formrecognizer container uses the ocr name and port.

    version: '3.3'
    services:   
      ocr:
        image: "containerpreview.azurecr.io/microsoft/cognitive-services-recognize-text"
        deploy:
          resources:
            limits:
              cpus: '2'
              memory: 8g
            reservations:
              cpus: '1'
              memory: 4g
        environment:
          eula: accept
          billing: "{COMPUTER_VISION_ENDPOINT_URI}"
          apikey: "{COMPUTER_VISION_API_KEY}"
    
      formrecognizer:
        image: "containerpreview.azurecr.io/microsoft/cognitive-services-form-recognizer"
        deploy:
          resources:
            limits:
              cpus: '2'
              memory: 8g
            reservations:
              cpus: '1'
              memory: 4g
        environment:
          eula: accept
          billing: "{FORM_RECOGNIZER_ENDPOINT_URI}"
          apikey: "{FORM_RECOGNIZER_API_KEY}"
          FormRecognizer__ComputerVisionApiKey: {COMPUTER_VISION_API_KEY}
          FormRecognizer__ComputerVisionEndpointUri: "http://ocr:5000"
          FormRecognizer__SyncProcessTaskCancelLimitInSecs: 75
        links:
          - ocr
        volumes:
          - type: bind
            source: c:\output
            target: /output
          - type: bind
            source: c:\input
            target: /input
        ports:
          - "5000:5000"
    

    重要

    Billing ApiKey您必須指定Eula、、和FormRecognizer:ComputerVisionApiKey以及和FormRecognizer:ComputerVisionEndpointUri選項,才能執行容器,否則容器將不會啟動。The Eula, Billing, and ApiKey, as well as the FormRecognizer:ComputerVisionApiKey and FormRecognizer:ComputerVisionEndpointUri options, must be specified to run the container; otherwise, the container won't start. 如需詳細資訊,請參閱帳單For more information, see Billing.

    查詢容器的預測端點Query the container's prediction endpoint

    容器Container 端點Endpoint
    form-recognizerform-recognizer http://localhost:5000

    表單辨識器Form Recognizer

    容器提供以 websocket 為基礎的查詢端點 Api,您可以透過表單辨識器服務 SDK 檔來存取。The container provides websocket-based query endpoint APIs, which you access through Form Recognizer services SDK documentation.

    根據預設,表單辨識器 SDK 會使用線上服務。By default, the Form Recognizer SDK uses the online services. 若要使用容器,您必須變更初始化方法。To use the container, you need to change the initialization method. 請參閱以下範例。See the examples below.

    針對 C#For C#

    從使用此 Azure 雲端初始化呼叫變更:Change from using this Azure-cloud initialization call:

    var config =
        FormRecognizerConfig.FromSubscription(
            "YourSubscriptionKey",
            "YourServiceRegion");
    

    此呼叫會使用容器端點:to this call, which uses the container endpoint:

    var config =
        FormRecognizerConfig.FromEndpoint(
            "ws://localhost:5000/formrecognizer/v1.0-preview/custom",
            "YourSubscriptionKey");
    

    針對 PythonFor Python

    從使用此 Azure 雲端初始化呼叫變更:Change from using this Azure-cloud initialization call:

    formrecognizer_config =
        formrecognizersdk.FormRecognizerConfig(
            subscription=formrecognizer_key, region=service_region)
    

    此呼叫會使用容器端點:to this call, which uses the container endpoint:

    formrecognizer_config = 
        formrecognizersdk.FormRecognizerConfig(
            subscription=formrecognizer_key,
            endpoint="ws://localhost:5000/formrecognizer/v1.0-preview/custom"
    

    表單辨識器Form Recognizer

    容器會提供 REST 端點 Api,您可以在表單辨識器 api頁面上找到它。The container provides REST endpoint APIs, which you can find on the Form Recognizer API page.

    驗證容器正在執行Validate that a container is running

    有數種方式可驗證容器正在執行。There are several ways to validate that the container is running. 找出有問題之容器的外部 IP位址和公開端口, 然後開啟您最愛的網頁瀏覽器。Locate the External IP address and exposed port of the container in question, and open your favorite web browser. 使用下列各種要求 Url 來驗證容器是否正在執行。Use the various request URLs below to validate the container is running. 下面所列的範例要求 url http://localhost:5000是, 但您的特定容器可能會有所不同。The example request URLs listed below are http://localhost:5000, but your specific container may vary. 請記住, 您會依賴容器的外部 IP位址和公開的埠。Keep in mind that you're to rely on your container's External IP address and exposed port.

    要求 URLRequest URL 用途Purpose
    http://localhost:5000/ 容器會提供首頁。The container provides a home page.
    http://localhost:5000/status 使用 HTTP GET 要求, 以驗證容器是否正在執行, 而不會造成端點查詢。Requested with an HTTP GET, to validate that the container is running without causing an endpoint query. 此要求可用來進行 Kubernetes 活躍度和整備度探查 (英文)。This request can be used for Kubernetes liveness and readiness probes.
    http://localhost:5000/swagger 容器會為端點提供一組完整的檔, 並使用 [試用] 功能。The container provides a full set of documentation for the endpoints and a Try it out feature. 使用此功能,您可以將自己的設定輸入至以 Web 為基礎的 HTML 表單並進行查詢,而無須撰寫任何程式碼。With this feature, you can enter your settings into a web-based HTML form and make the query without having to write any code. 當查詢傳回時,會提供範例 CURL 命令來示範所需的 HTTP 標頭和本文格式。After the query returns, an example CURL command is provided to demonstrate the HTTP headers and body format that's required.

    容器的首頁

    停止容器Stop the container

    若要關閉的容器,容器執行所在的命令列環境中選取Ctrl + CTo shut down the container, in the command-line environment where the container is running, select Ctrl+C.

    疑難排解Troubleshooting

    當您執行容器時,容器會使用stdoutstderr來輸出資訊,這有助於疑難排解啟動或執行容器時所發生的問題。When you run the container, the container uses stdout and stderr to output information that's helpful for troubleshooting issues that arise when you start or run the container.

    帳務Billing

    表單辨識器容器會使用您 Azure 帳戶上的_表單辨識器_資源,將帳單資訊傳送至 azure。The Form Recognizer containers send billing information to Azure by using a Form Recognizer resource on your Azure account.

    至容器的查詢會使用於 Azure 資源的定價層計費<ApiKey>Queries to the container are billed at the pricing tier of the Azure resource that's used for the <ApiKey>.

    Azure 認知服務容器在未連線至計費端點以進行計量的情況下,將無法被授權以執行。Azure Cognitive Services containers aren't licensed to run without being connected to the billing endpoint for metering. 您必須讓容器隨時都能與計量端點進行帳單資訊的通訊。You must enable the containers to communicate billing information with the billing endpoint at all times. 認知服務容器不會將客戶資料 (例如正在分析的影像或文字) 傳送至 Microsoft。Cognitive Services containers don't send customer data, such as the image or text that's being analyzed, to Microsoft.

    連接到 AzureConnect to Azure

    容器需要計費引數值才能執行。The container needs the billing argument values to run. 這些值讓容器能夠連線到計費端點。These values allow the container to connect to the billing endpoint. 容器會每隔 10 到 15 分鐘回報使用量。The container reports usage about every 10 to 15 minutes. 如果容器未在允許的時間範圍內連線到 Azure,容器會繼續執行,但在還原計費端點之前不會提供查詢。If the container doesn't connect to Azure within the allowed time window, the container continues to run but doesn't serve queries until the billing endpoint is restored. 以 10 到 15 分鐘的相同時間間隔嘗試連線 10 次。The connection is attempted 10 times at the same time interval of 10 to 15 minutes. 如果無法在 10 次嘗試內連線到計費端點,則容器會停止執行。If it can't connect to the billing endpoint within the 10 tries, the container stops running.

    計費引數Billing arguments

    針對docker run命令來啟動容器時,必須指定下列選項中的所有三個有效的值:For the docker run command to start the container, all three of the following options must be specified with valid values:

    選項Option 說明Description
    ApiKey 用來追蹤帳單資訊的認知服務資源的 API 金鑰。The API key of the Cognitive Services resource that's used to track billing information.
    此選項的值必須設定為 佈建的資源中指定的 API 金鑰BillingThe value of this option must be set to an API key for the provisioned resource that's specified in Billing.
    Billing 用來追蹤帳單資訊的認知服務資源端點。The endpoint of the Cognitive Services resource that's used to track billing information.
    此選項的值必須設定為已佈建 Azure 資源的端點 URI。The value of this option must be set to the endpoint URI of a provisioned Azure resource.
    Eula 表示您接受容器的授權。Indicates that you accepted the license for the container.
    此選項的值必須設定為接受The value of this option must be set to accept.

    如需這些選項的詳細資訊,請參閱設定容器For more information about these options, see Configure containers.

    部落格文章Blog posts

    開發人員範例Developer samples

    開發人員範例可從我們的 GitHub 存放庫取得。Developer samples are available at our GitHub repository.

    檢視網路研討會View webinar

    加入網路研討會以了解:Join the webinar to learn about:

    • 如何將認知服務部署到任何使用 Docker 的機器How to deploy Cognitive Services to any machine using Docker
    • 如何將認知服務部署到 AKSHow to deploy Cognitive Services to AKS

    總結Summary

    在本文中,您已了解下載、安裝及執行表單辨識器容器的概念和工作流程。In this article, you learned concepts and workflow for downloading, installing, and running Form Recognizer containers. 摘要說明:In summary:

    • 表單辨識器會針對 Docker 提供一個 Linux 容器。Form Recognizer provides one Linux container for Docker.
    • 容器映像是從 Azure 中的私人容器登錄下載。Container images are downloaded from the private container registry in Azure.
    • 容器映像是在 Docker 中執行。Container images run in Docker.
    • 您可以藉由指定容器的主機 URI,使用 REST API 或 REST SDK 來呼叫表單辨識器容器中的作業。You can use either the REST API or the REST SDK to call operations in Form Recognizer container by specifying the host URI of the container.
    • 當您具現化容器時,您必須指定帳單資訊。You must specify the billing information when you instantiate a container.

    重要

    認知服務容器在未連線至 Azure 以進行計量的情況下,將無法被授權以執行。Cognitive Services containers are not licensed to run without being connected to Azure for metering. 客戶必須啟用容器以持續與計量服務進行帳單資訊的通訊。Customers need to enable the containers to communicate billing information with the metering service at all times. 認知服務容器不會將客戶資料 (例如正在分析的影像或文字) 傳送至 Microsoft。Cognitive Services containers do not send customer data (for example, the image or text that is being analyzed) to Microsoft.

    後續步驟Next steps