設定 Language Understanding 的 Docker 容器Configure Language Understanding Docker containers

Language Understanding (LUIS) 容器執行階段環境可使用 docker run 命令引數來設定。The Language Understanding (LUIS) container runtime environment is configured using the docker run command arguments. LUIS 有數個必要的設定,和一些選擇性的設定。LUIS has several required settings, along with a few optional settings. 命令有相關範例可供參考。Several examples of the command are available. 容器專屬設定包括輸入裝載設定和計費設定。The container-specific settings are the input mount settings and the billing settings.

組態設定Configuration settings

此容器具有下列組態設定:This container has the following configuration settings:

必要Required 設定Setting 目的Purpose
Yes ApiKeyApiKey 用來追蹤帳單資訊。Used to track billing information.
No ApplicationInsightsApplicationInsights 可讓您將 Azure Application Insights 遙測支援新增至容器。Allows you to add Azure Application Insights telemetry support to your container.
Yes 計費Billing 指定 Azure 上服務資源的端點 URI。Specifies the endpoint URI of the service resource on Azure.
Yes EulaEula 表示您已接受容器的授權。Indicates that you've accepted the license for the container.
No FluentdFluentd 將記錄 (和選擇性的計量資料) 寫入至 Fluentd 伺服器。Write log and, optionally, metric data to a Fluentd server.
No HTTP ProxyHttp Proxy 設定 HTTP Proxy 以進行輸出要求。Configure an HTTP proxy for making outbound requests.
No LoggingLogging 提供適用於容器的 ASP.NET Core 記錄支援。Provides ASP.NET Core logging support for your container.
Yes 裝載Mounts 從主機電腦將資料讀取和寫入至容器,以及從容器將資料讀取和寫回主機電腦。Read and write data from host computer to container and from container back to host computer.

重要

系統會同時使用 ApiKeyBillingEula 設定,因此您必須同時為這三個設定提供有效的值,否則容器將不會啟動。The ApiKey, Billing, and Eula settings are used together, and you must provide valid values for all three of them; otherwise your container won't start. 如需使用這些組態設定來將容器具現化的詳細資訊,請參閱帳單For more information about using these configuration settings to instantiate a container, see Billing.

ApiKey 設定ApiKey setting

ApiKey 設定會指定用來追蹤容器帳單資訊的 Azure資源金鑰。The ApiKey setting specifies the Azure resource key used to track billing information for the container. 您必須指定 ApiKey 的值,且值必須是為Billing設定所指定之_認知服務_資源的有效金鑰。You must specify a value for the ApiKey and the value must be a valid key for the Cognitive Services resource specified for the Billing configuration setting.

此設定可在下列位置找到:This setting can be found in the following places:

  • Azure 入口網站:認知服務的資源管理,位於 [金鑰] 下方Azure portal: Cognitive Services Resource Management, under Keys
  • LUIS 入口網站: [金鑰和端點設定] 頁面。LUIS portal: Keys and Endpoint settings page.

請勿使用入門金鑰或撰寫金鑰。Do not use the starter key or the authoring key.

ApplicationInsights 設定ApplicationInsights setting

ApplicationInsights 設定可讓您將 Azure Application Insights 遙測支援新增至容器。The ApplicationInsights setting allows you to add Azure Application Insights telemetry support to your container. Application Insights 可提供深入容器監視。Application Insights provides in-depth monitoring of your container. 您可輕鬆監視容器的可用性、效能和使用情形。You can easily monitor your container for availability, performance, and usage. 您也可以快速識別並診斷容器中的錯誤。You can also quickly identify and diagnose errors in your container.

下表說明 ApplicationInsights 區段下所支援的組態設定。The following table describes the configuration settings supported under the ApplicationInsights section.

必要Required 名稱Name 資料類型Data type 說明Description
No InstrumentationKey 字串String Application Insights 執行個體的檢測金鑰,容器的遙測資料會傳送到這裡。The instrumentation key of the Application Insights instance to which telemetry data for the container is sent. 如需詳細資訊,請參閱 ASP.NET Core 的 Application InsightsFor more information, see Application Insights for ASP.NET Core.

範例:Example:
InstrumentationKey=123456789

帳單支援Billing setting

Billing 設定會指定 Azure 上用來計量容器帳單資訊的_認知服務_資源端點 URI。The Billing setting specifies the endpoint URI of the Cognitive Services resource on Azure used to meter billing information for the container. 您必須指定此設定的值,且該值必須是 Azure 上_認知服務_資源的有效端點 URI。You must specify a value for this configuration setting, and the value must be a valid endpoint URI for a Cognitive Services resource on Azure. 容器會每隔 10 到 15 分鐘回報使用量。The container reports usage about every 10 to 15 minutes.

此設定可在下列位置找到:This setting can be found in the following places:

  • Azure 入口網站:認知服務總覽,加上標籤 EndpointAzure portal: Cognitive Services Overview, labeled Endpoint
  • LUIS 入口網站: [金鑰和端點設定] 頁面,做為端點 URI 的一部分。LUIS portal: Keys and Endpoint settings page, as part of the endpoint URI.
必要Required 名稱Name 資料類型Data type 說明Description
Yes Billing 字串string 計費端點 URI。Billing endpoint URI. 如需取得帳單 URI 的詳細資訊,請參閱收集必要的參數For more information on obtaining the billing URI, see gathering required parameters. 如需詳細資訊和完整的區域端點清單,請參閱認知服務的自訂子網域名稱For more information and a complete list of regional endpoints, see Custom subdomain names for Cognitive Services.

Eula 設定Eula setting

Eula 設定可指出您已接受容器的授權。The Eula setting indicates that you've accepted the license for the container. 您必須為此組態設定指定值,且該值必須設定為 acceptYou must specify a value for this configuration setting, and the value must be set to accept.

必要Required 名稱Name 資料類型Data type 描述Description
Yes Eula 字串String 接受授權License acceptance

範例:Example:
Eula=accept

認知服務容器是在您的合約 (控管您對於 Azure 的使用) 底下獲得授權。Cognitive Services containers are licensed under your agreement governing your use of Azure. 如果您沒有可控管您使用 Azure 的現有合約,您同意控管使用 Azure 的合約是 Microsoft 線上訂閱合約 (其中包含線上服務條款)。If you do not have an existing agreement governing your use of Azure, you agree that your agreement governing use of Azure is the Microsoft Online Subscription Agreement, which incorporates the Online Services Terms. 對於預覽版,您也同意 Microsoft Azure 預覽專用的補充使用條款For previews, you also agree to the Supplemental Terms of Use for Microsoft Azure Previews. 使用容器即表示您同意這些條款。By using the container you agree to these terms.

Fluentd 設定Fluentd settings

Fluentd 是適用於統一記錄的開放原始碼資料收集器。Fluentd is an open-source data collector for unified logging. Fluentd 設定可管理容器對 Fluentd 伺服器的連線。The Fluentd settings manage the container's connection to a Fluentd server. 容器包含 Fluentd 記錄提供者,可讓您的容器將記錄 (及選擇性的計量資料) 寫入至 Fluentd 伺服器。The container includes a Fluentd logging provider, which allows your container to write logs and, optionally, metric data to a Fluentd server.

下表說明 Fluentd 區段下所支援的組態設定。The following table describes the configuration settings supported under the Fluentd section.

名稱Name 資料類型Data type 描述Description
Host 字串String Fluentd 伺服器的 IP 位址或 DNS 主機名稱。The IP address or DNS host name of the Fluentd server.
Port 整數Integer Fluentd 伺服器的連接埠。The port of the Fluentd server.
預設值為 24224。The default value is 24224.
HeartbeatMs 整數Integer 活動訊號間隔,以毫秒為單位。The heartbeat interval, in milliseconds. 如果在此間隔到期之前未傳送任何事件流量,系統便會將活動訊號傳送至 Fluentd 伺服器。If no event traffic has been sent before this interval expires, a heartbeat is sent to the Fluentd server. 預設值為 60000 毫秒 (1 分鐘)。The default value is 60000 milliseconds (1 minute).
SendBufferSize 整數Integer 針對傳送作業所配置的網路緩衝空間,以位元組為單位。The network buffer space, in bytes, allocated for send operations. 預設值為 32768 個位元組 (32 KB)。The default value is 32768 bytes (32 kilobytes).
TlsConnectionEstablishmentTimeoutMs 整數Integer 向 Fluentd 伺服器建立 SSL/TLS 連線的逾時,以毫秒為單位。The timeout, in milliseconds, to establish a SSL/TLS connection with the Fluentd server. 預設值是 10000 毫秒 (10 秒)。The default value is 10000 milliseconds (10 seconds).
如果將 UseTLS 設定為 false,便會忽略此值。If UseTLS is set to false, this value is ignored.
UseTLS BooleanBoolean 指出容器是否應使用 SSL/TLS 來與 Fluentd 伺服器通訊。Indicates whether the container should use SSL/TLS for communicating with the Fluentd server. 預設值為 False。The default value is false.

HTTP proxy 認證設定HTTP proxy credentials settings

如果您需要設定 HTTP Proxy 以進行輸出要求,請使用以下兩個引數:If you need to configure an HTTP proxy for making outbound requests, use these two arguments:

名稱Name 資料類型Data type 描述Description
HTTP_PROXYHTTP_PROXY stringstring 要使用的 Proxy,例如 http://proxy:8888The proxy to use, for example, http://proxy:8888
<proxy-url>
HTTP_PROXY_CREDSHTTP_PROXY_CREDS stringstring 對 Proxy 進行驗證時所需的任何認證,例如 username:password。Any credentials needed to authenticate against the proxy, for example, username:password.
<proxy-user> stringstring Proxy 的使用者。The user for the proxy.
<proxy-password> stringstring 對於 Proxy 與 <proxy-user> 相關聯的密碼。The password associated with <proxy-user> for the proxy.
docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
--mount type=bind,src=/home/azureuser/output,target=/output \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
HTTP_PROXY=<proxy-url> \
HTTP_PROXY_CREDS=<proxy-user>:<proxy-password> \

記錄設定Logging settings

Logging 設定可管理適用於容器的 ASP.NET Core 記錄支援。The Logging settings manage ASP.NET Core logging support for your container. 對於您用於 ASP.NET Core 應用程式的容器,您可以使用相同的組態設定和值。You can use the same configuration settings and values for your container that you use for an ASP.NET Core application.

容器支援下列記錄提供者:The following logging providers are supported by the container:

提供者Provider 用途Purpose
ConsoleConsole ASP.NET Core Console 記錄提供者。The ASP.NET Core Console logging provider. 支援此記錄提供者的所有 ASP.NET Core 組態設定和預設值。All of the ASP.NET Core configuration settings and default values for this logging provider are supported.
偵錯Debug ASP.NET Core Debug 記錄提供者。The ASP.NET Core Debug logging provider. 支援此記錄提供者的所有 ASP.NET Core 組態設定和預設值。All of the ASP.NET Core configuration settings and default values for this logging provider are supported.
磁碟Disk JSON 記錄提供者。The JSON logging provider. 此記錄提供者會將記錄資料寫入至輸出裝載。This logging provider writes log data to the output mount.

此容器命令會以 JSON 格式,將記錄資訊儲存於輸出裝載中:This container command stores logging information in the JSON format to the output mount:

docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
--mount type=bind,src=/home/azureuser/output,target=/output \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
Logging:Disk:Format=json

此容器命令會在容器執行時顯示偵錯資訊 (前面加上 dbug):This container command shows debugging information, prefixed with dbug, while the container is running:

docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
Logging:Console:LogLevel:Default=Debug

磁碟記錄Disk logging

Disk 記錄提供者支援下列組態設定:The Disk logging provider supports the following configuration settings:

名稱Name 資料類型Data type 描述Description
Format StringString 適用於記錄檔的輸出格式。The output format for log files.
注意: 此值必須設定為 json 以啟用記錄提供者。Note: This value must be set to json to enable the logging provider. 如果在具現化期間指定此值,但沒有同時指定輸出裝載,便會發生錯誤。If this value is specified without also specifying an output mount while instantiating a container, an error occurs.
MaxFileSize 整數Integer 記錄檔的大小上限,以 MB 為單位。The maximum size, in megabytes (MB), of a log file. 當目前記錄檔的大小符合或超過此值時,記錄提供者便會建立新的記錄檔。When the size of the current log file meets or exceeds this value, a new log file is started by the logging provider. 如果指定 -1,記錄檔的大小便只會受限於輸出裝載的檔案大小上限 (若有的話)。If -1 is specified, the size of the log file is limited only by the maximum file size, if any, for the output mount. 預設值為 1。The default value is 1.

如需設定 ASP.NET Core 記錄支援的詳細資訊,請參閱設定檔案組態For more information about configuring ASP.NET Core logging support, see Settings file configuration.

裝載設定Mount settings

使用繫結裝載將資料讀取和寫入至容器,及從中讀取和寫入。Use bind mounts to read and write data to and from the container. 您可以在 --mountdocker run 命令中指定 選項,以指定輸入裝載或輸出裝載。You can specify an input mount or output mount by specifying the --mount option in the docker run command.

LUIS 容器不會使用輸入或輸出裝載來儲存訓練或服務資料。The LUIS container doesn't use input or output mounts to store training or service data.

主機裝載位置的正確語法會隨著主機作業系統而有所不同。The exact syntax of the host mount location varies depending on the host operating system. 此外,主機電腦的裝載位置可能會因為 Docker 服務帳戶所使用的權限與主機裝載位置的權限互相衝突,而無法存取。Additionally, the host computer's mount location may not be accessible due to a conflict between permissions used by the docker service account and the host mount location permissions.

下表說明支援的設定。The following table describes the settings supported.

必要Required 名稱Name 資料類型Data type 說明Description
Yes Input 字串String 輸入裝載的目標。The target of the input mount. 預設值為 /inputThe default value is /input. 這是 LUIS 套件檔案的位置。This is the location of the LUIS package files.

範例:Example:
--mount type=bind,src=c:\input,target=/input
No Output 字串String 輸出裝載的目標。The target of the output mount. 預設值為 /outputThe default value is /output. 這是記錄的位置。This is the location of the logs. 其中包括 LUIS 查詢記錄和容器記錄。This includes LUIS query logs and container logs.

範例:Example:
--mount type=bind,src=c:\output,target=/output

範例 docker run 命令Example docker run commands

下列範例會使用組態設定來說明如何撰寫和使用 docker run 命令。The following examples use the configuration settings to illustrate how to write and use docker run commands. 開始執行後,容器就會持續執行,直到您加以停止Once running, the container continues to run until you stop it.

  • 這些範例會使用 C: 磁片磁碟機的目錄,以避免在 Windows 上發生任何許可權衝突。These examples use the directory off the C: drive to avoid any permission conflicts on Windows. 如果您需要使用特定目錄作為輸入目錄,您可能需要授與 Docker 服務權限。If you need to use a specific directory as the input directory, you may need to grant the docker service permission.
  • 若非十分熟悉 Docker 容器,請勿變更引數的順序。Do not change the order of the arguments unless you are very familiar with docker containers.
  • 如果您使用不同的作業系統,請使用正確的主控台/終端機、裝載的資料夾語法,以及系統的行接續字元。If you are using a different operating system, use the correct console/terminal, folder syntax for mounts, and line continuation character for your system. 這些範例假設 Windows 主控台的行接續字元 ^These examples assume a Windows console with a line continuation character ^. 因為容器是 Linux 作業系統,所以目標掛接會使用 Linux 樣式的資料夾語法。Because the container is a Linux operating system, the target mount uses a Linux-style folder syntax.

請將 {argument_name} 取代為您自己的值:Replace {argument_name} with your own values:

PlaceholderPlaceholder Value 格式或範例Format or example
{API_KEY}{API_KEY} [Azure LUIS 金鑰] 頁面上 LUIS 資源的端點金鑰。The endpoint key of the LUIS resource on the Azure LUIS Keys page. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}{ENDPOINT_URI} [計費端點] 值可在 Azure LUIS [總覽] 頁面取得。The billing endpoint value is available on the Azure LUIS Overview page. 如需明確的範例,請參閱收集必要的參數See gathering required parameters for explicit examples.

注意

2019 年 7 月 1 日之後建立的新資源會使用自訂的子網域名稱。New resources created after July 1, 2019, will use custom subdomain names. 如需詳細資訊和完整的區域端點清單,請參閱認知服務的自訂子網域名稱For more information and a complete list of regional endpoints, see Custom subdomain names for Cognitive Services.

重要

必須指定 EulaBillingApiKey 選項以執行容器,否則容器將不會啟動。The Eula, Billing, and ApiKey options must be specified to run the container; otherwise, the container won't start. 如需詳細資訊,請參閱帳單For more information, see Billing. ApiKey 值是 LUIS 入口網站中 [金鑰] 和 [端點] 頁面的金鑰,也可以在 [Azure Cognitive Services 資源金鑰] 頁面上取得。The ApiKey value is the Key from the Keys and Endpoints page in the LUIS portal and is also available on the Azure Cognitive Services resource keys page.

基本範例Basic example

下列範例會以最少的引數來執行容器:The following example has the fewest arguments possible to run the container:

docker run --rm -it -p 5000:5000 --memory 4g --cpus 2 ^
--mount type=bind,src=c:\input,target=/input ^
--mount type=bind,src=c:\output,target=/output ^
mcr.microsoft.com/azure-cognitive-services/luis:latest ^
Eula=accept ^
Billing={ENDPOINT_URL} ^
ApiKey={API_KEY}

ApplicationInsights 範例ApplicationInsights example

下列範例會設定 ApplicationInsights 引數,以在容器執行時將遙測資料傳送至 Application Insights:The following example sets the ApplicationInsights argument to send telemetry to Application Insights while the container is running:

docker run --rm -it -p 5000:5000 --memory 6g --cpus 2 ^
--mount type=bind,src=c:\input,target=/input ^
--mount type=bind,src=c:\output,target=/output ^
mcr.microsoft.com/azure-cognitive-services/luis:latest ^
Eula=accept ^
Billing={ENDPOINT_URL} ^
ApiKey={API_KEY} ^
InstrumentationKey={INSTRUMENTATION_KEY}

記錄範例Logging example

下列命令會設定記錄層級 Logging:Console:LogLevel,以將記錄層級設定為 InformationThe following command sets the logging level, Logging:Console:LogLevel, to configure the logging level to Information.

docker run --rm -it -p 5000:5000 --memory 6g --cpus 2 ^
--mount type=bind,src=c:\input,target=/input ^
--mount type=bind,src=c:\output,target=/output ^
mcr.microsoft.com/azure-cognitive-services/luis:latest ^
Eula=accept ^
Billing={ENDPOINT_URL} ^
ApiKey={API_KEY} ^
Logging:Console:LogLevel:Default=Information

後續步驟Next steps