配置异常检测器容器Configure Anomaly Detector containers

异常检测器容器运行时环境是使用 docker run 命令参数配置的。The Anomaly Detector container runtime environment is configured using the docker run command arguments. 此容器有多个必需设置,以及一些可选设置。This container has several required settings, along with a few optional settings. 多个示例命令均可用。Several examples of the command are available. 容器专用设置是帐单设置。The container-specific settings are 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 BillingBilling 指定 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 代理Http Proxy 配置 HTTP 代理以发出出站请求。Configure an HTTP proxy for making outbound requests.
No 日志记录Logging 为容器提供 ASP.NET Core 日志记录支持。Provides ASP.NET Core logging support for your container.
No MountsMounts 从主计算机读取数据并将其写入到容器,以及从容器读回数据并将其写回到主计算机。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 configuration 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 Anomaly Detector resource specified for the Billing configuration setting.

可以在以下位置找到此设置:This setting can be found in the following place:

  • Azure 门户:异常检测器的资源管理,位于“密钥”下 Azure portal: Anomaly Detector's Resource Management, under Keys

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 NameName 数据类型Data type 说明Description
No InstrumentationKey StringString 容器遥测数据要发送到的 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 配置设置Billing configuration setting

Billing 设置指定 Azure 上用于计量容器的账单信息的异常检测器资源的终结点 URI。The Billing setting specifies the endpoint URI of the Anomaly Detector 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 an Anomaly Detector resource on Azure.

可以在以下位置找到此设置:This setting can be found in the following place:

  • Azure 门户:异常检测器的概述,标记为 EndpointAzure portal: Anomaly Detector's Overview, labeled Endpoint
必须Required 名称Name 数据类型Data type 说明Description
Yes Billing StringString 账单终结点 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 NameName 数据类型Data type 说明Description
Yes Eula StringString 接受许可证License acceptance

示例:Example:
Eula=accept

根据管理 Azure 使用的协议授予认知服务容器许可。Cognitive Services containers are licensed under your agreement governing your use of Azure. 如果没有管理 Azure 使用情况的现有协议,则表示你同意管理 Azure 使用情况的协议是 Azure 在线订阅协议,其中包含联机服务条款If you do not have an existing agreement governing your use of Azure, you agree that your agreement governing use of Azure is the Azure Online Subscription Agreement, which incorporates the Online Services Terms. 对于预览版,你还同意 Azure 预览版补充使用条款For previews, you also agree to the Supplemental Terms of Use for 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.

NameName 数据类型Data type 说明Description
Host StringString Fluentd 服务器的 IP 地址或 DNS 主机名。The IP address or DNS host name of the Fluentd server.
Port IntegerInteger Fluentd 服务器的端口。The port of the Fluentd server.
默认值为 24224。The default value is 24224.
HeartbeatMs IntegerInteger 检测信号间隔,以毫秒为单位。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 IntegerInteger 为发送操作分配的网络缓冲空间,以字节为单位。The network buffer space, in bytes, allocated for send operations. 默认值为 32768 字节(32 KB)。The default value is 32768 bytes (32 kilobytes).
TlsConnectionEstablishmentTimeoutMs IntegerInteger 与 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 布尔Boolean 指示容器是否应使用 SSL/TLS 来与 Fluentd 服务器通信。Indicates whether the container should use SSL/TLS for communicating with the Fluentd server. 默认值为 false。The default value is false.

Http 代理凭据设置Http proxy credentials settings

如果需要配置 HTTP 代理以发出出站请求,请使用以下两个参数:If you need to configure an HTTP proxy for making outbound requests, use these two arguments:

NameName 数据类型Data type 说明Description
HTTP_PROXYHTTP_PROXY stringstring 要使用的代理,例如 http://proxy:8888The proxy to use, for example, http://proxy:8888
<proxy-url>
HTTP_PROXY_CREDSHTTP_PROXY_CREDS stringstring 对代理进行身份验证所需的凭据,例如 username:password。Any credentials needed to authenticate against the proxy, for example, username:password.
<proxy-user> stringstring 代理的用户。The user for the proxy.
<proxy-password> stringstring 与代理的 <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.
DiskDisk 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 日志记录Disk logging

Disk 日志记录提供程序支持以下配置设置:The Disk logging provider supports the following configuration settings:

NameName 数据类型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 IntegerInteger 日志文件的最大大小,以 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. 可以通过在 docker run 命令中指定 --mount 选项来指定输入装载或输出装载。You can specify an input mount or output mount by specifying the --mount option in the docker run command.

异常检测器容器不使用输入或输出装载来存储训练或服务数据。The Anomaly Detector containers don'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.

可选Optional 名称Name 数据类型Data type 说明Description
不允许Not allowed Input StringString 异常检测器容器不使用此项。Anomaly Detector containers do not use this.
可选Optional Output StringString 输出装入点的目标。The target of the output mount. 默认值为 /outputThe default value is /output. 这是日志的位置。This is the location of the logs. 这包括容器日志。This includes container logs.

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

Docker 运行命令示例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.

  • 行继续符:以下各部分中的 Docker 命令使用反斜杠 (\) 作为 bash shell 行继续符。Line-continuation character: The Docker commands in the following sections use the back slash, \, as a line continuation character for a bash shell. 根据主机操作系统的要求替换或删除字符。Replace or remove this based on your host operating system's requirements. 例如,Windows 的行继续符是插入符号 ^For example, the line continuation character for windows is a caret, ^. 将反斜杠替换为插入符号。Replace the back slash with the caret.
  • 参数顺序:除非熟悉 Docker 容器,否则请勿更改参数的顺序。Argument order: Do not change the order of the arguments unless you are very familiar with Docker containers.

将大括号 {} 中的值替换为你自己的值:Replace value in brackets, {}, with your own values:

占位符Placeholder ValueValue 格式或示例Format or example
{API_KEY}{API_KEY} “Azure Anomaly Detector 密钥”页上的 Anomaly Detector 资源的终结点密钥。The endpoint key of the Anomaly Detector resource on the Azure Anomaly Detector Keys page. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}{ENDPOINT_URI} Azure Anomaly Detector“概览”页面上提供了账单终结点值。The billing endpoint value is available on the Azure Anomaly Detector 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.

重要

必须指定 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 值是 Azure 异常检测器“资源密钥”页中提供的密钥。The ApiKey value is the Key from the Azure Anomaly Detector Resource keys page.

异常检测器容器 Docker 示例Anomaly Detector container Docker examples

以下 Docker 示例适用于异常检测器容器。The following Docker examples are for the Anomaly Detector container.

基本示例Basic example

docker run --rm -it -p 5000:5000 --memory 4g --cpus 1 \
mcr.microsoft.com/azure-cognitive-services/decision/anomaly-detector \
Eula=accept \
Billing={ENDPOINT_URI} \
ApiKey={API_KEY} 

使用命令行参数的日志记录示例Logging example with command-line arguments

docker run --rm -it -p 5000:5000 --memory 4g --cpus 1 \
mcr.microsoft.com/azure-cognitive-services/decision/anomaly-detector \
Eula=accept \
Billing={ENDPOINT_URI} ApiKey={API_KEY} \
Logging:Console:LogLevel:Default=Information

后续步骤Next steps