使用健康情況容器的文字分析

容器可讓您在自己的基礎結構上裝載健康情況 API 的文字分析。 如果您的安全性或資料治理需求無法藉由從遠端呼叫健康情況的文字分析來滿足,則容器可能是不錯的選擇。

如果您沒有 Azure 訂用帳戶,請在開始前先建立免費帳戶

必要條件

使用健康情況的文字分析容器之前,您必須符合下列必要條件。 如果您沒有 Azure 訂用帳戶,請在開始前先建立免費帳戶

  • 主機電腦上已安裝了 Docker。 Docker 必須設定為允許容器與 Azure 連線,以及傳送帳單資料至 Azure。
    • 在 Windows 上,也必須將 Docker 設定為支援 Linux 容器。
    • 您應該對 Docker 概念有基本的了解。
  • 以免費 (F0) 或標準 (S) 定價層語言資源

收集必要參數

需要所有 Azure AI 容器的三個主要參數。 Microsoft 軟體授權條款必須具有接受值。 也需要端點 URI 和 API 金鑰。

端點 URI

{ENDPOINT_URI} 值可在相對應 Azure AI 服務資源的 Azure 入口網站 [概觀] 頁面上取得。 移至 [概觀] 頁面,將滑鼠停留在端點上,然後會出現 [複製到剪貼簿] 圖示。 複製端點並用在需要之處。

顯示收集供稍後使用的端點 URI 的螢幕擷取畫面。

索引鍵

{API_KEY} 值可用來啟動容器,並可在相對應 Azure AI 服務資源的 Azure 入口網站 [金鑰] 頁面上取得。 移至 [金鑰] 頁面,然後選取 [複製到剪貼簿] 圖示。

此螢幕擷取畫面顯示取得兩個金鑰其中之一供稍後使用。

重要事項

這些訂用帳戶金鑰可用於存取 Azure AI 服務 API。 請勿共用您的金鑰。 安全地儲存金鑰。 例如,使用 Azure Key Vault。 我們也建議您定期重新產生這些金鑰。 進行 API 呼叫時,只需要一個金鑰。 重新產生第一個金鑰時,您可以使用第二個金鑰繼續存取服務。

主機電腦的需求和建議

主機是執行 Docker 容器的 x64 型電腦。 它可以是您內部部署的電腦,或是在 Azure 中裝載服務的 Docker,例如:

下表描述健康情況文字分析容器的最小和建議規格。 每個 CPU 核心必須至少 2.6 GHz 或更快。 也會列出允許的每秒交易數 (TPS)。

最低主機規格 建議的主機規格 最小 TP 最大 TPS
1 個文件/要求 4 核心,12GB 記憶體 6 核心,12GB 記憶體 15 30
10 個文件/要求 6 核心,16 GB 記憶體 8 核心,20 GB 記憶體 15 30

CPU 核心和記憶體會對應至 --cpus--memory 設定,用來做為 docker run 命令的一部分。

使用 docker pull 取得容器映像

您可以在 mcr.microsoft.com 容器登錄聯盟上找到健康狀態的文字分析容器映像。 其位於 azure-cognitive-services/textanalytics/ 存放庫內,並命名為 healthcare。 完整的容器映像名稱為 mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare

若要使用最新版本的容器,您可以使用 latest 標記。 您也可以在 MCR 上找到標籤的完整清單。

使用 docker pull 命令從 Microsoft 公用容器登錄下載此容器映像。 您可以在Microsoft Container Registry上找到精選標籤

docker pull mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:<tag-name>

提示

您可以使用 docker images \(英文\) 命令來列出已下載的容器映像。 例如,下列命令會列出每個已下載之容器映像的識別碼、存放庫和標籤,並將它格式化為表格:

docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"

IMAGE ID         REPOSITORY                TAG
<image-id>       <repository-path/name>    <tag-name>

透過 docker run 執行容器

一旦容器位於主機電腦後,請使用 docker run 命令來執行容器。 容器將會繼續執行,直到您將其停止為止。

重要

  • 以下幾節的 Docker 命令會使用反斜線 \ 作為行接續字元。 請根據您主機作業系統的需求加以替換或移除。
  • 必須指定 EulaBillingApiKey 選項以執行容器,否則容器將不會啟動。 如需詳細資訊,請參閱帳單
  • 情感分析和語言偵測容器會使用 API 的 v3,並已正式推出。 關鍵片語擷取容器會使用 API 的 v2,且目前為預覽狀態。

您可以透過多種方式來安裝及執行健康情況的文字分析容器。

  • 使用 Azure 入口網站來建立語言資源,並使用 Docker 來取得您的容器。
  • 使用具有 Docker 的 Azure VM 來執行容器。 請參閱 Azure 上的 Docker
  • 使用下列 PowerShell 和 Azure CLI 指令碼,將資源部署和容器設定自動化。

當您使用健康情況的文字分析容器時,Microsoft 將看不到您的 API 要求和回應中所包含的資料,且資料也不會用於定型套用至您資料的模型。

在本機執行容器

若要在下載容器映像之後,在您自己的環境中執行容器,請執行下列 docker run 命令。 將下列預留位置取代為您自己的值:

預留位置 格式或範例
{API_KEY} 語言資源的金鑰。 在 Azure 入口網站上,您可以在資源的 [金鑰和端點] 頁面上找到金鑰。 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI} 用來存取 API 的端點。 在 Azure 入口網站上,您可以在資源的 [金鑰和端點] 頁面上找到金鑰。 https://<your-custom-subdomain>.cognitiveservices.azure.com
docker run --rm -it -p 5000:5000 --cpus 6 --memory 12g \
mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:<tag-name> \
Eula=accept \
rai_terms=accept \
Billing={ENDPOINT_URI} \
ApiKey={API_KEY} 

此命令:

  • 從容器映像執行健康情況的文字分析容器
  • 配置 6 個 CPU 核心和 12 GB 的記憶體
  • 公開 TCP 連接埠 5000,並為容器配置虛擬 TTY
  • 接受使用者授權合約 (EULA) 和負責任 AI (RAI) 條款
  • 在容器結束之後自動將其移除。 容器映像仍可在主機電腦上使用。

以視覺化方式呈現輸出的示範 UI

容器會提供以 REST 為基礎的查詢預測端點 API。 我們也在容器中提供視覺效果工具,可透過將 /demo 附加至容器的端點來存取。 例如:

http://<serverURL>:5000/demo

使用下列範例 cURL 要求將查詢提交至您已部署的容器,並將 serverURL 變數取代為適當的值。

curl -X POST 'http://<serverURL>:5000/text/analytics/v3.1/entities/health' --header 'Content-Type: application/json' --header 'accept: application/json' --data-binary @example.json

使用 Azure 用於容器的 Web App 安裝容器

Azure 用於容器的 Web App 是專門用來在雲端中執行容器的 Azure 資源。 其會提供現成的功能,例如自動調整、支援 Docker 容器和 Docker 撰寫、HTTPS 支援,以及其他更多功能。

注意

使用 Azure Web 應用程式時,您將會自動取得格式為 <appservice_name>.azurewebsites.net 的網域

使用 Azure CLI 來執行此 PowerShell 指令碼,以使用您的訂用帳戶和透過 HTTPS 的容器映像來建立用於容器的 Web App。 請先等候指令碼完成 (大約 25-30 分鐘) ,然後再提交第一個要求。

$subscription_name = ""                    # THe name of the subscription you want you resource to be created on.
$resource_group_name = ""                  # The name of the resource group you want the AppServicePlan
                                           #    and AppSerivce to be attached to.
$resources_location = ""                   # This is the location you wish the AppServicePlan to be deployed to.
                                           #    You can use the "az account list-locations -o table" command to
                                           #    get the list of available locations and location code names.
$appservice_plan_name = ""                 # This is the AppServicePlan name you wish to have.
$appservice_name = ""                      # This is the AppService resource name you wish to have.
$TEXT_ANALYTICS_RESOURCE_API_KEY = ""      # This should be taken from the Language resource.
$TEXT_ANALYTICS_RESOURCE_API_ENDPOINT = "" # This should be taken from the Language resource.
$DOCKER_IMAGE_NAME = "mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:latest"

az login
az account set -s $subscription_name
az appservice plan create -n $appservice_plan_name -g $resource_group_name --is-linux -l $resources_location --sku P3V2
az webapp create -g $resource_group_name -p $appservice_plan_name -n $appservice_name -i $DOCKER_IMAGE_NAME 
az webapp config appsettings set -g $resource_group_name -n $appservice_name --settings Eula=accept rai_terms=accept Billing=$TEXT_ANALYTICS_RESOURCE_API_ENDPOINT ApiKey=$TEXT_ANALYTICS_RESOURCE_API_KEY

# Once deployment complete, the resource should be available at: https://<appservice_name>.azurewebsites.net

使用 Azure 容器執行個體安裝容器

您也可以使用 Azure 容器執行個體 (ACI) 讓部署更輕鬆。 ACI 是一項資源,可讓您在受控、無伺服器的 Azure 環境中,視需要執行 Docker 容器。

請參閱如何使用 Azure 容器執行個體,以取得使用 Azure 入口網站部署 ACI 資源的步驟。 您也可以使用下列 PowerShell 指令碼搭配 Azure CLI,這會使用容器映像在您的訂用帳戶上建立 ACI。 請先等候指令碼完成 (大約 25-30 分鐘) ,然後再提交第一個要求。 由於每個 ACI 資源 CPU 數目上限的限制,如果您想要對每個要求提交 5 個以上的大型文件 (大約 5000 個字元),請不要選取此選項。 如需可用性資訊,請參閱 ACI 區域支援文章。

注意

Azure 容器執行個體不包含內建網域的 HTTPS 支援。 如果您需要 HTTPS,您將需要手動加以設定,包括建立憑證和註冊網域。 您可以使用下面的 NGINX 找到相關指示。

$subscription_name = ""                    # The name of the subscription you want you resource to be created on.
$resource_group_name = ""                  # The name of the resource group you want the AppServicePlan
                                           # and AppService to be attached to.
$resources_location = ""                   # This is the location you wish the web app to be deployed to.
                                           # You can use the "az account list-locations -o table" command to
                                           # Get the list of available locations and location code names.
$azure_container_instance_name = ""        # This is the AzureContainerInstance name you wish to have.
$TEXT_ANALYTICS_RESOURCE_API_KEY = ""      # This should be taken from the Language resource.
$TEXT_ANALYTICS_RESOURCE_API_ENDPOINT = "" # This should be taken from the Language resource.
$DNS_LABEL = ""                            # This is the DNS label name you wish your ACI will have
$DOCKER_IMAGE_NAME = "mcr.microsoft.com/azure-cognitive-services/textanalytics/healthcare:latest"

az login
az account set -s $subscription_name
az container create --resource-group $resource_group_name --name $azure_container_instance_name --image $DOCKER_IMAGE_NAME --cpu 4 --memory 12 --port 5000 --dns-name-label $DNS_LABEL --environment-variables Eula=accept rai_terms=accept Billing=$TEXT_ANALYTICS_RESOURCE_API_ENDPOINT ApiKey=$TEXT_ANALYTICS_RESOURCE_API_KEY

# Once deployment complete, the resource should be available at: http://<unique_dns_label>.<resource_group_region>.azurecontainer.io:5000

安全 ACI 連線能力

依預設,使用 ACI 搭配容器 API 時,不會提供任何安全性。 這是因為容器通常會做為 Pod 的一部分來執行,而該 Pod 是由網路橋接器從外部保護。 不過,您可以修改具有正面元件的容器,讓容器保持為私人端點。 下列範例會使用 NGINX 做為輸入閘道,以支援 HTTPS/SSL 和用戶端憑證驗證。

注意

NGINX 是開放原始碼、高效能的 HTTP 伺服器和 Proxy。 NGINX 容器可以用來終止單一容器的 TLS 連線。 也可能有更複雜的 NGINX 輸入型 TLS 終止解決方案。

將 NGINX 設定為輸入閘道

NGINX 會在執行階段使用組態檔來啟用功能。 若要啟用另一個服務的 TLS 終止,您必須指定 SSL 憑證來終止 TLS 連線,以及 proxy_pass 來指定服務的位址。 以下提供範例。

注意

ssl_certificate 需要在 NGINX 容器的本機檔案系統內指定路徑。 必須可從 NGINX 容器的網路內取得針對 proxy_pass 指定的位址。

NGINX 容器會將裝載在 /etc/nginx/conf.d/ 下的 _.conf_ 中所有的檔案載入至 HTTP 設定路徑。

server {
  listen              80;
  return 301 https://$host$request_uri;
}
server {
  listen              443 ssl;
  # replace with .crt and .key paths
  ssl_certificate     /cert/Local.crt;
  ssl_certificate_key /cert/Local.key;

  location / {
    proxy_pass http://cognitive-service:5000;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP  $remote_addr;
  }
}

Docker Compose 檔案範例

下列範例顯示如何建立 Docker Compose 檔案,以部署 NGINX 和健康情況容器:

version: "3.7"
services:
  cognitive-service:
    image: {IMAGE_ID}
    ports:
      - 5000:5000
    environment:
      - eula=accept
      - billing={ENDPOINT_URI}
      - apikey={API_KEY}
    volumes:
        # replace with path to logs folder
      - <path-to-logs-folder>:/output
  nginx:
    image: nginx
    ports:
      - 443:443
    volumes:
        # replace with paths for certs and conf folders
      - <path-to-certs-folder>:/cert
      - <path-to-conf-folder>:/etc/nginx/conf.d/

若要起始此 Docker Compose 檔案,請從位於檔案根目錄層級的主控台中執行下列命令:

docker-compose up

如需詳細資訊,請參閱有關 NGINX SSL 終止的 NGINX 文件。

在相同主機上執行多個容器

如果您打算使用公開的連接埠執行多個容器,請務必使用不同的公開連接埠來執行每個容器。 例如,在連接埠 5000 上執行第一個容器,以及在連接埠 5001 上執行第二個容器。

您可以讓此容器和不同的 Azure AI 服務容器在主機上一起執行。 您也可以針對相同的 Azure AI 服務容器執行多個容器。

查詢容器的預測端點

容器會提供以 REST 為基礎的查詢預測端點 API。

請對容器 API 使用主機 http://localhost:5000

驗證容器正在執行

有數種方式可驗證容器正在執行。 找出有問題容器的外部 IP 位址和公開的連接埠,然後開啟您最愛的網頁瀏覽器。 使用下列各種要求 URL 來驗證容器是否正在執行。 此處列出的範例要求 URL 為 http://localhost:5000,但您的特定容器可能會有所不同。 請確保您將會依賴容器的外部 IP 位址和公開的連接埠。

要求 URL 用途
http://localhost:5000/ 容器會提供首頁。
http://localhost:5000/ready 以 GET 提出要求,此 URL 將會驗證容器是否已準備好接受對模型的查詢。 此要求可用來進行 Kubernetes 活躍度和整備度探查 \(英文\)。
http://localhost:5000/status 也會以 GET 提出要求,此 URL 會在不需進行端點查詢的同時,確認用來啟動容器的 API 金鑰是否有效。 此要求可用來進行 Kubernetes 活躍度和整備度探查 \(英文\)。
http://localhost:5000/swagger 容器會為端點提供一組完整的文件和 [立即試用] 功能。 使用此功能,您可以將自己的設定輸入至以 Web 為基礎的 HTML 表單並進行查詢,而無須撰寫任何程式碼。 當查詢傳回時,會提供範例 CURL 命令來示範所需的 HTTP 標頭和本文格式。

容器的首頁

建立容器的 API 要求結構

您可以使用 Postman 或下列範例 cURL 要求將查詢提交至您已部署的容器,並將 serverURL 變數取代為適當的值。 請注意,容器 URL 中的 API 版本與託管的 API 不同。

注意

最新的容器提供快速健康照護互通資源 (FHIR) 功能,並透過新的語言 REST API 公開。

curl -i -X POST 'http://<serverURL>:5000/language/analyze-text/jobs?api-version=2022-04-01-preview' --header 'Content-Type: application/json' --header --data-binary @example.json

下列 JSON 範例是 JSON 檔案附加至語言要求的 POST 本文:

example.json

{
    "analysisInput": {
        "documents": [
            {
                "text": "The doctor prescried 200mg Ibuprofen.",
                "language": "en",
                "id": "1"
            }
        ]
    },
    "tasks": [
        {
            "taskName": "analyze 1",
            "kind": "Healthcare",
            "parameters": {
                "fhirVersion": "4.0.1"
            }
        }
    ]
}

容器回應主體

下列 JSON 範例是來自容器化同步呼叫的語言回應主體:

{
  "jobId": "{JOB-ID}",
  "lastUpdateDateTime": "2022-04-18T15:50:16Z",
  "createdDateTime": "2022-04-18T15:50:14Z",
  "expirationDateTime": "2022-04-19T15:50:14Z",
  "status": "succeeded",
  "errors": [],
  "tasks": {
    "completed": 1,
    "failed": 0,
    "inProgress": 0,
    "total": 1,
    "items": [
      {
        "kind": "HealthcareLROResults",
        "taskName": "analyze 1",
        "lastUpdateDateTime": "2022-04-18T15:50:16.7046515Z",
        "status": "succeeded",
        "results": {
          "documents": [
            {
              "id": "1",
              "entities": [
                {
                  "offset": 4,
                  "length": 6,
                  "text": "doctor",
                  "category": "HealthcareProfession",
                  "confidenceScore": 0.76
                },
                {
                  "offset": 21,
                  "length": 5,
                  "text": "200mg",
                  "category": "Dosage",
                  "confidenceScore": 0.99
                },
                {
                  "offset": 27,
                  "length": 9,
                  "text": "Ibuprofen",
                  "category": "MedicationName",
                  "confidenceScore": 1.0,
                  "name": "ibuprofen",
                  "links": [
                    { "dataSource": "UMLS", "id": "C0020740" },
                    { "dataSource": "AOD", "id": "0000019879" },
                    { "dataSource": "ATC", "id": "M01AE01" },
                    { "dataSource": "CCPSS", "id": "0046165" },
                    { "dataSource": "CHV", "id": "0000006519" },
                    { "dataSource": "CSP", "id": "2270-2077" },
                    { "dataSource": "DRUGBANK", "id": "DB01050" },
                    { "dataSource": "GS", "id": "1611" },
                    { "dataSource": "LCH_NW", "id": "sh97005926" },
                    { "dataSource": "LNC", "id": "LP16165-0" },
                    { "dataSource": "MEDCIN", "id": "40458" },
                    { "dataSource": "MMSL", "id": "d00015" },
                    { "dataSource": "MSH", "id": "D007052" },
                    { "dataSource": "MTHSPL", "id": "WK2XYI10QM" },
                    { "dataSource": "NCI", "id": "C561" },
                    { "dataSource": "NCI_CTRP", "id": "C561" },
                    { "dataSource": "NCI_DCP", "id": "00803" },
                    { "dataSource": "NCI_DTP", "id": "NSC0256857" },
                    { "dataSource": "NCI_FDA", "id": "WK2XYI10QM" },
                    { "dataSource": "NCI_NCI-GLOSS", "id": "CDR0000613511" },
                    { "dataSource": "NDDF", "id": "002377" },
                    { "dataSource": "PDQ", "id": "CDR0000040475" },
                    { "dataSource": "RCD", "id": "x02MO" },
                    { "dataSource": "RXNORM", "id": "5640" },
                    { "dataSource": "SNM", "id": "E-7772" },
                    { "dataSource": "SNMI", "id": "C-603C0" },
                    { "dataSource": "SNOMEDCT_US", "id": "387207008" },
                    { "dataSource": "USP", "id": "m39860" },
                    { "dataSource": "USPMG", "id": "MTHU000060" },
                    { "dataSource": "VANDF", "id": "4017840" }
                  ]
                }
              ],
              "relations": [
                {
                  "relationType": "DosageOfMedication",
                  "entities": [
                    {
                      "ref": "#/results/documents/0/entities/1",
                      "role": "Dosage"
                    },
                    {
                      "ref": "#/results/documents/0/entities/2",
                      "role": "Medication"
                    }
                  ]
                }
              ],
              "warnings": [],
              "fhirBundle": {
                "resourceType": "Bundle",
                "id": "bae9d4e0-191e-48e6-9c24-c1ff6097c439",
                "meta": {
                  "profile": [
                    "http://hl7.org/fhir/4.0.1/StructureDefinition/Bundle"
                  ]
                },
                "identifier": {
                  "system": "urn:ietf:rfc:3986",
                  "value": "urn:uuid:bae9d4e0-191e-48e6-9c24-c1ff6097c439"
                },
                "type": "document",
                "entry": [
                  {
                    "fullUrl": "Composition/9044c2cc-dcec-4b9d-b005-bfa8be978aa8",
                    "resource": {
                      "resourceType": "Composition",
                      "id": "9044c2cc-dcec-4b9d-b005-bfa8be978aa8",
                      "status": "final",
                      "type": {
                        "coding": [
                          {
                            "system": "http://loinc.org",
                            "code": "11526-1",
                            "display": "Pathology study"
                          }
                        ],
                        "text": "Pathology study"
                      },
                      "subject": {
                        "reference": "Patient/5c554347-4290-4b05-83ac-6637ff3bfb40",
                        "type": "Patient"
                      },
                      "encounter": {
                        "reference": "Encounter/6fe12f5b-e35c-4c92-a492-96feda5a1a3b",
                        "type": "Encounter",
                        "display": "unknown"
                      },
                      "date": "2022-04-18",
                      "author": [
                        {
                          "reference": "Practitioner/fb5da4d8-e0f0-4434-8d29-4419b065c4d7",
                          "type": "Practitioner",
                          "display": "Unknown"
                        }
                      ],
                      "title": "Pathology study",
                      "section": [
                        {
                          "title": "General",
                          "code": {
                            "coding": [
                              {
                                "system": "",
                                "display": "Unrecognized Section"
                              }
                            ],
                            "text": "General"
                          },
                          "text": {
                            "div": "<div>\r\n\t\t\t\t\t\t\t<h1>General</h1>\r\n\t\t\t\t\t\t\t<p>The doctor prescried 200mg Ibuprofen.</p>\r\n\t\t\t\t\t</div>"
                          },
                          "entry": [
                            {
                              "reference": "List/db388912-b5fb-4073-a74c-2751fd3374dd",
                              "type": "List",
                              "display": "General"
                            }
                          ]
                        }
                      ]
                    }
                  },
                  {
                    "fullUrl": "Practitioner/fb5da4d8-e0f0-4434-8d29-4419b065c4d7",
                    "resource": {
                      "resourceType": "Practitioner",
                      "id": "fb5da4d8-e0f0-4434-8d29-4419b065c4d7",
                      "extension": [
                        {
                          "extension": [
                            { "url": "offset", "valueInteger": -1 },
                            { "url": "length", "valueInteger": 7 }
                          ],
                          "url": "http://hl7.org/fhir/StructureDefinition/derivation-reference"
                        }
                      ],
                      "name": [{ "text": "Unknown", "family": "Unknown" }]
                    }
                  },
                  {
                    "fullUrl": "Patient/5c554347-4290-4b05-83ac-6637ff3bfb40",
                    "resource": {
                      "resourceType": "Patient",
                      "id": "5c554347-4290-4b05-83ac-6637ff3bfb40",
                      "gender": "unknown"
                    }
                  },
                  {
                    "fullUrl": "Encounter/6fe12f5b-e35c-4c92-a492-96feda5a1a3b",
                    "resource": {
                      "resourceType": "Encounter",
                      "id": "6fe12f5b-e35c-4c92-a492-96feda5a1a3b",
                      "meta": {
                        "profile": [
                          "http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"
                        ]
                      },
                      "status": "finished",
                      "class": {
                        "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                        "display": "unknown"
                      },
                      "subject": {
                        "reference": "Patient/5c554347-4290-4b05-83ac-6637ff3bfb40",
                        "type": "Patient"
                      }
                    }
                  },
                  {
                    "fullUrl": "MedicationStatement/24e860ce-2fdc-4745-aa9e-7d30bb487c4e",
                    "resource": {
                      "resourceType": "MedicationStatement",
                      "id": "24e860ce-2fdc-4745-aa9e-7d30bb487c4e",
                      "extension": [
                        {
                          "extension": [
                            { "url": "offset", "valueInteger": 27 },
                            { "url": "length", "valueInteger": 9 }
                          ],
                          "url": "http://hl7.org/fhir/StructureDefinition/derivation-reference"
                        }
                      ],
                      "status": "active",
                      "medicationCodeableConcept": {
                        "coding": [
                          {
                            "system": "http://www.nlm.nih.gov/research/umls",
                            "code": "C0020740",
                            "display": "Ibuprofen"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/aod",
                            "code": "0000019879"
                          },
                          {
                            "system": "http://www.whocc.no/atc",
                            "code": "M01AE01"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/ccpss",
                            "code": "0046165"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/chv",
                            "code": "0000006519"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/csp",
                            "code": "2270-2077"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/drugbank",
                            "code": "DB01050"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/gs",
                            "code": "1611"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/lch_nw",
                            "code": "sh97005926"
                          },
                          { "system": "http://loinc.org", "code": "LP16165-0" },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/medcin",
                            "code": "40458"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/mmsl",
                            "code": "d00015"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/msh",
                            "code": "D007052"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/mthspl",
                            "code": "WK2XYI10QM"
                          },
                          {
                            "system": "http://ncimeta.nci.nih.gov",
                            "code": "C561"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nci_ctrp",
                            "code": "C561"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nci_dcp",
                            "code": "00803"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nci_dtp",
                            "code": "NSC0256857"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nci_fda",
                            "code": "WK2XYI10QM"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nci_nci-gloss",
                            "code": "CDR0000613511"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/nddf",
                            "code": "002377"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/pdq",
                            "code": "CDR0000040475"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/rcd",
                            "code": "x02MO"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/rxnorm",
                            "code": "5640"
                          },
                          {
                            "system": "http://snomed.info/sct",
                            "code": "E-7772"
                          },
                          {
                            "system": "http://snomed.info/sct/900000000000207008",
                            "code": "C-603C0"
                          },
                          {
                            "system": "http://snomed.info/sct/731000124108",
                            "code": "387207008"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/usp",
                            "code": "m39860"
                          },
                          {
                            "system": "http://www.nlm.nih.gov/research/umls/uspmg",
                            "code": "MTHU000060"
                          },
                          {
                            "system": "http://hl7.org/fhir/ndfrt",
                            "code": "4017840"
                          }
                        ],
                        "text": "Ibuprofen"
                      },
                      "subject": {
                        "reference": "Patient/5c554347-4290-4b05-83ac-6637ff3bfb40",
                        "type": "Patient"
                      },
                      "context": {
                        "reference": "Encounter/6fe12f5b-e35c-4c92-a492-96feda5a1a3b",
                        "type": "Encounter",
                        "display": "unknown"
                      },
                      "dosage": [
                        {
                          "text": "200mg",
                          "doseAndRate": [{ "doseQuantity": { "value": 200 } }]
                        }
                      ]
                    }
                  },
                  {
                    "fullUrl": "List/db388912-b5fb-4073-a74c-2751fd3374dd",
                    "resource": {
                      "resourceType": "List",
                      "id": "db388912-b5fb-4073-a74c-2751fd3374dd",
                      "status": "current",
                      "mode": "snapshot",
                      "title": "General",
                      "subject": {
                        "reference": "Patient/5c554347-4290-4b05-83ac-6637ff3bfb40",
                        "type": "Patient"
                      },
                      "encounter": {
                        "reference": "Encounter/6fe12f5b-e35c-4c92-a492-96feda5a1a3b",
                        "type": "Encounter",
                        "display": "unknown"
                      },
                      "entry": [
                        {
                          "item": {
                            "reference": "MedicationStatement/24e860ce-2fdc-4745-aa9e-7d30bb487c4e",
                            "type": "MedicationStatement",
                            "display": "Ibuprofen"
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          ],
          "errors": [],
          "modelVersion": "2022-03-01"
        }
      }
    ]
  }
}

使用用戶端程式庫支援執行容器

從容器版本 3.0.017010001-onprem-amd64 開始 (或如果您使用 latest 容器),您可以使用用戶端程式庫執行健康情況文字分析容器。 若要這樣做,請將下列參數新增至 docker run 命令:

enablelro=true

之後當您驗證用戶端物件時,請使用您容器執行所在的端點:

http://localhost:5000

例如,如果您使用的是 C#,會使用下列程式碼:

var client = new TextAnalyticsClient("http://localhost:5000", "your-text-analytics-key");

停止容器

若要關閉容器,請在容器執行所在的命令列環境中,選取 [Ctrl+C]

疑難排解

如果您在啟用輸出掛接和記錄的情況下執行容器,容器將會產生記錄檔,有助於排解在啟動或執行容器時所發生的問題。

提示

如需詳細資訊和指引,請參閱 Azure AI 容器常見問題 (常見問題)

計費

健康情況文字分析容器會使用您 Azure 帳戶上的語言資源傳送計費資訊至 Azure。

對於容器的查詢,會以針對 ApiKey 參數使用的 Azure 資源定價層來計費。

Azure AI 服務容器若未連線至計量或計費端點,即無法獲得執行的授權。 您必須讓容器隨時都能與計量端點進行帳單資訊的通訊。 Azure AI 服務容器不會將客戶資料 (例如正在分析的影像或文字) 傳送給 Microsoft。

連線到 Azure

容器需要計費引數值才能執行。 這些值讓容器能夠連線到計費端點。 容器會每隔 10 到 15 分鐘回報使用量。 如果容器未在允許的時間範圍內連線到 Azure,容器會繼續執行,但在還原計費端點之前不會提供查詢。 以 10 到 15 分鐘的相同時間間隔嘗試連線 10 次。 如果無法在 10 次嘗試內連線到計費端點,則容器會停止回應要求。 請參閱「Azure AI 服務容器常見問題集」,以獲得需傳送哪些資訊給 Microsoft 以供計費的範例。

計費引數

當下列三個選項都填入了有效值時,docker run 命令將會啟動容器:

選項 描述
ApiKey Azure AI 服務資源的 API 金鑰,用於追蹤計費資訊。
此選項值必須設定為已佈建 Billing 指定資源的 API 金鑰。
Billing Azure AI 服務資源的端點,用於追蹤計費資訊。
此選項的值必須設定為已佈建 Azure 資源的端點 URI。
Eula 表示您接受容器的授權。
此選項的值必須設定為接受

總結

在本文中,您已了解下載、安裝及執行健康情況文字分析容器的概念和工作流程。 摘要說明:

  • 健康情況的文字分析提供適用於 Docker 的 Linux 容器
  • 容器映像可從 Microsoft Container Registry (MCR) 下載取得。
  • 容器映像是在 Docker 中執行。
  • 您可以指定容器的主機 URI,來使用 REST API 或 SDK 呼叫健康情況文字分析容器中的作業。
  • 將容器具現化時,您必須指定帳單資訊。

重要

Azure AI 容器若未連線至用於計量的 Azure,即無法獲得執行的授權。 客戶必須啟用容器以持續與計量服務進行帳單資訊的通訊。 Azure AI 容器不會將客戶資料 (例如正在分析的文字) 傳送給 Microsoft。

下一步