替代默认终结点的 Application InsightsApplication Insights overriding default endpoints

若要将 Application Insights 中的数据发送到某些区域,需要替代默认终结点地址。To send data from Application Insights to certain regions, you'll need to override the default endpoint addresses. 每个 SDK 都需要进行稍有不同的修改,本文将对所有这些修改进行说明。Each SDK requires slightly different modifications, all of which are described in this article. 这些更改需要调整示例代码,并将 QuickPulse_Endpoint_AddressTelemetryChannel_Endpoint_AddressProfile_Query_Endpoint_address 的占位符值替换为特定区域的实际终结点地址。These changes require adjusting the sample code and replacing the placeholder values for QuickPulse_Endpoint_Address, TelemetryChannel_Endpoint_Address, and Profile_Query_Endpoint_address with the actual endpoint addresses for your specific region. 本文末尾包含指向需要此配置的区域的终结点地址的链接。The end of this article contains links to the endpoint addresses for regions where this configuration is required.

备注

连接字符串是在 Application Insights 中设置自定义终结点的新首选方法。Connection strings are the new preferred method of setting custom endpoints within Application Insights.


SDK 代码更改SDK code changes

备注

每次执行 SDK 升级时,都会自动重写 applicationinsights.config 文件。The applicationinsights.config file is automatically overwritten anytime a SDK upgrade is performed. 执行 SDK 升级后,请确保重新输入区域特定的终结点值。After performing an SDK upgrade be sure to re-enter the region specific endpoint values.

<ApplicationInsights>
  ...
  <TelemetryModules>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector">
      <QuickPulseServiceEndpoint>Custom_QuickPulse_Endpoint_Address</QuickPulseServiceEndpoint>
    </Add>
  </TelemetryModules>
    ...
  <TelemetryChannel>
     <EndpointAddress>TelemetryChannel_Endpoint_Address</EndpointAddress>
  </TelemetryChannel>
  ...
  <ApplicationIdProvider Type="Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights">
    <ProfileQueryEndpoint>Profile_Query_Endpoint_address</ProfileQueryEndpoint>
  </ApplicationIdProvider>
  ...
</ApplicationInsights>

需要修改终结点的区域Regions that require endpoint modification

目前唯一需要修改终结点的区域是 Azure 政府Azure 中国Currently the only regions that require endpoint modifications are Azure Government and Azure China.

区域Region 终结点名称Endpoint Name ValueValue
Azure 中国Azure China 遥测通道Telemetry Channel https://dc.applicationinsights.azure.cn/v2/track
Azure 中国Azure China QuickPulse(实时指标)QuickPulse (Live Metrics) https://live.applicationinsights.azure.cn/QuickPulseService.svc
Azure 中国Azure China 配置文件查询Profile Query https://dc.applicationinsights.azure.cn/api/profiles/{0}/appId
Azure GovernmentAzure Government 遥测通道Telemetry Channel https://dc.applicationinsights.us/v2/track
Azure GovernmentAzure Government QuickPulse(实时指标)QuickPulse (Live Metrics) https://quickpulse.applicationinsights.us/QuickPulseService.svc
Azure GovernmentAzure Government 配置文件查询Profile Query https://dc.applicationinsights.us/api/profiles/{0}/appId

如果当前使用的是 Application Insights REST API(通常通过“api.applicationinsights.io”访问),则需要使用你所在地区的本地终结点:If you currently use the Application Insights REST API which is normally accessed via `api.applicationinsights.io', you will need to use an endpoint that is local to your region:

区域Region 终结点名称Endpoint Name ValueValue
Azure 中国Azure China REST APIREST API api.applicationinsights.azure.cn

备注

Azure 应用服务的基于无代码代理/扩展的监视在这些区域目前不受支持Codeless agent/extension based monitoring for Azure App Services is currently not supported in these regions. 一旦该功能可用,本文将立即更新。As soon as this functionality becomes available this article will be updated.

后续步骤Next steps