使用 Application Insights 探查实时 Azure Service Fabric 应用程序Profile live Azure Service Fabric applications with Application Insights
Application Insights Profiler 也可以部署在以下服务上:You can also deploy Application Insights Profiler on these services:
设置环境部署定义Set up the environment deployment definition
Azure 诊断中包括了 Application Insights Profiler。Application Insights Profiler is included with Azure Diagnostics. 可以使用 Azure 资源管理器模板为 Service Fabric 群集安装 Azure 诊断扩展。You can install the Azure Diagnostics extension by using an Azure Resource Manager template for your Service Fabric cluster. 获取在 Service Fabric 群集上安装 Azure 诊断的模板。Get a template that installs Azure Diagnostics on a Service Fabric Cluster.
若要设置环境,请执行以下操作:To set up your environment, take the following actions:
Profiler 支持 .NET Framework 和 .Net Core。Profiler supports .NET Framework and .Net Core. 如果使用的是 .NET Framework,请确保使用 .NET Framework 4.6.1 或更高版本。If you're using .NET Framework, make sure you're using .NET Framework 4.6.1 or later. 只需确认部署的 OS 是
Windows Server 2012 R2
或更高版本。It's sufficient to confirm that the deployed OS isWindows Server 2012 R2
or later. Profiler 支持 .NET Core 2.1 及更高版本的应用程序。Profiler supports .NET Core 2.1 and newer applications.在部署模板文件中搜索 Azure 诊断。Search for the Azure Diagnostics extension in the deployment template file.
添加以下
SinksConfig
部分作为WadCfg
的子元素。Add the followingSinksConfig
section as a child element ofWadCfg
. 使用自己的 Application Insights 检测密钥替换ApplicationInsightsProfiler
属性值:Replace theApplicationInsightsProfiler
property value with your own Application Insights instrumentation key:"SinksConfig": { "Sink": [ { "name": "MyApplicationInsightsProfilerSink", "ApplicationInsightsProfiler": "00000000-0000-0000-0000-000000000000" } ] }
若要了解如何将诊断扩展添加到部署模板,请参阅将监视和诊断与 Windows VM 和 Azure 资源管理器模板配合使用。For information about adding the Diagnostics extension to your deployment template, see Use monitoring and diagnostics with a Windows VM and Azure Resource Manager templates.
使用 Azure 资源管理器模板部署 Service Fabric 群集。Deploy your Service Fabric cluster by using your Azure Resource Manager template.
如果你的设置正确,则在安装 Azure 诊断扩展时将安装并启用 Application Insights Profiler。If your settings are correct, Application Insights Profiler will be installed and enabled when the Azure Diagnostics extension is installed.将 Application Insights 添加到你的 Service Fabric 应用程序。Add Application Insights to your Service Fabric application.
要使 Profiler 收集请求的配置文件,应用程序必须使用 Application Insights 跟踪操作。For Profiler to collect profiles for your requests, your application must be tracking operations with Application Insights. 对于无状态 API,可以参考跟踪分析请求的说明。For stateless APIs, you can refer to instructions for tracking Requests for profiling. 有关在其他类型的应用中跟踪自定义操作的详细信息,请参阅使用 Application Insights .NET SDK 跟踪自定义操作。For more information about tracking custom operations in other kinds of apps, see track custom operations with Application Insights .NET SDK.重新部署应用程序。Redeploy your application.
后续步骤Next steps
- 请参阅 Azure 门户中的 Profiler 跟踪。See Profiler traces in the Azure portal.
- 排查 Profiler 问题时如需帮助,请参阅 Profiler 故障排除。For help with troubleshooting Profiler issues, see Profiler troubleshooting.