2

我目前正在试验新的 beta asp.net 核心应用洞察分析器。

但是我看到错误消息:

2019-02-11T11:36:22 PID[6036] 信息 02-11 11:36:22 错误:代理主进程中出现意外异常。详细信息:Microsoft.ServiceProfiler.Utilities.AppIdNotFoundException:无法找到 iKey 的 AppId

在诊断日志中。

在 github https://github.com/Microsoft/ApplicationInsights-Profiler-AspNetCore/issues/36上提出问题,我被告知这可能是由于旧的分析器变得活跃,并给出了一些关于如何禁用它的提示。

不幸的是,将 APPINSIGHTS_PROFILERFEATURE_VERSION 设置为禁用对我不起作用(尽管可能是由于我的特定 ARM 模板设置)。

相反,通过 Kudu 禁用对我有帮助(因为我需要将其作为发布管道的一部分):

4

2 回答 2

1

ApplicationInsightsProfiler2 webjob 由旧的 Application Insights 站点扩展安装。要正确删除它,您需要从应用服务页面内的“扩展”刀片中删除 ApplicationInsights 扩展。

如果这不起作用(您看不到 ApplicationInsights 扩展),则卸载可能会静默失败,但这些位仍然存在,因此您必须按照此处的步骤手动删除它。

GitHub 评论指的是安装名为“ApplicationInsightsProfiler3”的 Web 作业的新启用流程(来自应用服务页面内的“Application Insights”刀片)。如果您只有此 Web 作业,则可以从 Application Insights UI 将其关闭 - 您无需手动设置应用程序设置。

于 2019-02-13T21:17:03.180 回答
0

在深入研究了 kudu wiki 并用更新的技术替换了一些元素之后,我使用了以下 powershell。

它使用从站点获取的发布凭据组成一个“http 基本身份验证”字符串,然后使用它向 kudu api 发出 DELETE 请求。

值得注意的是,如果您使用的是 Powershell 6,则不需要编写基本身份验证字符串,因为 Powershell 6 的 Invoke-RestMethod 可以为您完成此操作。

function Get-KuduSiteBasicAuthString
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        $ResourceGroupName,

        [Parameter(Mandatory = $true)]
        $Name
    )

    $response = Get-AzureRmWebAppPublishingProfile -ResourceGroupName $ResourceGroupName -Name $Name

    $publishingCredentials = [xml]$response

    $username = $publishingCredentials.publishData.publishProfile[0].userName
    $password = $publishingCredentials.publishData.publishProfile[0].userPWD

    $credentialsString = "{0}:{1}" -f $username, $password

    $credentialsAsByteArray = [Text.Encoding]::ASCII.GetBytes($credentialsString)

    "Basic {0}" -f [Convert]::ToBase64String($credentialsAsByteArray)
}

$ResourceGroupName = "your resource group name"
$ApplicationName = "your app name"

$kuduAuthString = Get-KuduSiteBasicAuthString -ResourceGroupName $ResourceGroupName -Name $ApplicationName

$apiUrl = "https://" + $ApplicationName + ".scm.azurewebsites.net/api/continuouswebjobs/ApplicationInsightsProfiler2"
Invoke-RestMethod -Uri $apiUrl -Headers @{ 'Authorization' = $kuduAuthString } -Method Delete -Verbose
于 2019-02-13T11:18:17.223 回答