首页 > 解决方案 > 通过 ARM 部署时无法在 QnA Maker 中创建 KB(未找到端点密钥)

问题描述

我遇到了一个问题,我无法在 QnA Maker 中为我通过 ARM 模板/DevOps 部署的服务创建 KB。这里和 Github 上存在许多问题,但主要建议(在同一区域创建所有资源,不要在应用服务计划中添加任何其他内容,删除并重新部署)对我不起作用。如前所述,资源已被多次创建和删除,名称相同,所以我不知道这是否是问题的一部分。资源创建得很好(认知服务、应用服务、应用服务计划、天蓝色搜索和应用洞察),都在 WestUS,但是我无法通过 API 或直接在 qnamaker.ai 创建知识库。在这两种情况下,我都会收到错误消息:

未找到端点键

我可以通过 Azure CLI 获取密钥,而且它们会显示在门户中,所以这不是问题。发布新 KB 后生成/显示的 Authorization EndpointKey 可能存在问题,但由于我无法创建或发布一个,因此我找不到此密钥。不确定这是否是错误消息所指的关键。

这是我用来设置资源的 ARM 模板。

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sites_etn_qnamaker_name": {
            "defaultValue": "etn-qnamaker",
            "type": "string"
        },
        "serverfarms_etn_qnamaker_name": {
            "defaultValue": "etn-qnamaker",
            "type": "string"
        },
        "components_etn_qnamaker_ai_name": {
            "defaultValue": "etn-qnamaker-ai",
            "type": "string"
        },
        "accounts_etn_qnamaker_name": {
            "defaultValue": "etn-qnamaker",
            "type": "string"
        },
        "searchServices_etnqnamaker_azsearch_name": {
            "defaultValue": "etnqnamaker-azsearch",
            "type": "string"
        },
        "smartdetectoralertrules_failure_anomalies___etn_qnamaker_ai_name": {
            "defaultValue": "failure anomalies - etn-qnamaker-ai",
            "type": "string"
        },
        "actiongroups_application_20insights_20smart_20detection_externalid": {
            "defaultValue": "/subscriptions/REDACTED/resourceGroups/avcnc-chatbot-rg/providers/microsoft.insights/actiongroups/application%20insights%20smart%20detection",
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.CognitiveServices/accounts",
            "apiVersion": "2017-04-18",
            "name": "[parameters('accounts_etn_qnamaker_name')]",
            "location": "westus",
            "sku": {
                "name": "S0"
            },
            "kind": "QnAMaker",
            "properties": {
                "apiProperties": {
                    "qnaRuntimeEndpoint": "[concat('https://', parameters('accounts_etn_qnamaker_name'), '.azurewebsites.net')]"
                },
                "customSubDomainName": "[parameters('accounts_etn_qnamaker_name')]"
            }
        },
        {
            "type": "Microsoft.Insights/components",
            "apiVersion": "2015-05-01",
            "name": "[parameters('components_etn_qnamaker_ai_name')]",
            "location": "westus",
            "tags": {
                "hidden-link:/subscriptions/REDACTED/resourceGroups/ENTP-Chatbot-rg/providers/Microsoft.Web/sites/etn-qnamaker": "Resource"
            },
            "kind": "web",
            "properties": {
                "Application_Type": "web"
            }
        },
        {
            "type": "Microsoft.Search/searchServices",
            "apiVersion": "2015-08-19",
            "name": "[parameters('searchServices_etnqnamaker_azsearch_name')]",
            "location": "West US",
            "sku": {
                "name": "basic"
            },
            "properties": {
                "replicaCount": 1,
                "partitionCount": 1,
                "hostingMode": "default"
            }
        },
        {
            "type": "Microsoft.Web/serverfarms",
            "apiVersion": "2018-02-01",
            "name": "[parameters('serverfarms_etn_qnamaker_name')]",
            "location": "West US",
            "sku": {
                "name": "S1",
                "tier": "Standard",
                "size": "S1",
                "family": "S",
                "capacity": 1
            },
            "kind": "app",
            "properties": {
                "perSiteScaling": false,
                "maximumElasticWorkerCount": 1,
                "isSpot": false,
                "reserved": false,
                "isXenon": false,
                "hyperV": false,
                "targetWorkerCount": 0,
                "targetWorkerSizeId": 0
            }
        },
        {
            "type": "microsoft.alertsmanagement/smartdetectoralertrules",
            "apiVersion": "2019-06-01",
            "name": "[parameters('smartdetectoralertrules_failure_anomalies___etn_qnamaker_ai_name')]",
            "location": "global",
            "dependsOn": [
                "[resourceId('microsoft.insights/components', parameters('components_etn_qnamaker_ai_name'))]"
            ],
            "properties": {
                "description": "Failure Anomalies notifies you of an unusual rise in the rate of failed HTTP requests or dependency calls.",
                "state": "Enabled",
                "severity": "Sev3",
                "frequency": "PT1M",
                "detector": {
                    "id": "FailureAnomaliesDetector",
                    "name": "Failure Anomalies",
                    "description": "Detects if your application experiences an abnormal rise in the rate of HTTP requests or dependency calls that are reported as failed. The anomaly detection uses machine learning algorithms and occurs in near real time, therefore there's no need to define a frequency for this signal.<br/></br/>To help you triage and diagnose the problem, an analysis of the characteristics of the failures and related telemetry is provided with the detection. This feature works for any app, hosted in the cloud or on your own servers, that generates request or dependency telemetry - for example, if you have a worker role that calls <a class=\"ext-smartDetecor-link\" href=\\\"https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics#trackrequest\\\" target=\\\"_blank\\\">TrackRequest()</a> or <a class=\"ext-smartDetecor-link\" href=\\\"https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics#trackdependency\\\" target=\\\"_blank\\\">TrackDependency()</a>.",
                    "supportedResourceTypes": [
                        "ApplicationInsights"
                    ],
                    "imagePaths": [
                        "https://globalsmartdetectors.blob.core.windows.net/detectors/FailureAnomaliesDetector/v0.18/FailureAnomaly.png"
                    ]
                },
                "scope": [
                    "[resourceId('microsoft.insights/components', parameters('components_etn_qnamaker_ai_name'))]"
                ],
                "actionGroups": {
                    "groupIds": [
                        "[parameters('actiongroups_application_20insights_20smart_20detection_externalid')]"
                    ]
                }
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-11-01",
            "name": "[parameters('sites_etn_qnamaker_name')]",
            "location": "West US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_etn_qnamaker_name'))]"
            ],
            "tags": {
                "hidden-related:/subscriptions/REDACTED/resourcegroups/ENTP-Chatbot-rg/providers/Microsoft.Web/serverfarms/etn-qnamaker": "empty"
            },
            "kind": "app",
            "properties": {
                "enabled": true,
                "hostNameSslStates": [
                    {
                        "name": "[concat(parameters('sites_etn_qnamaker_name'), '.azurewebsites.net')]",
                        "sslState": "Disabled",
                        "hostType": "Standard"
                    },
                    {
                        "name": "[concat(parameters('sites_etn_qnamaker_name'), '.scm.azurewebsites.net')]",
                        "sslState": "Disabled",
                        "hostType": "Repository"
                    }
                ],
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_etn_qnamaker_name'))]",
                "reserved": false,
                "isXenon": false,
                "hyperV": false,
                "scmSiteAlsoStopped": false,
                "clientAffinityEnabled": true,
                "clientCertEnabled": false,
                "hostNamesDisabled": false,
                "containerSize": 0,
                "dailyMemoryTimeQuota": 0,
                "httpsOnly": false,
                "redundancyMode": "None"
            }
        },
        {
            "type": "Microsoft.Web/sites/config",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('sites_etn_qnamaker_name'), '/web')]",
            "location": "West US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('sites_etn_qnamaker_name'))]"
            ],
            "tags": {
                "hidden-related:/subscriptions/REDACTED/resourcegroups/ENTP-Chatbot-rg/providers/Microsoft.Web/serverfarms/etn-qnamaker": "empty"
            },
            "properties": {
                "numberOfWorkers": 1,
                "defaultDocuments": [
                    "Default.htm",
                    "Default.html",
                    "Default.asp",
                    "index.htm",
                    "index.html",
                    "iisstart.htm",
                    "default.aspx",
                    "index.php",
                    "hostingstart.html"
                ],
                "netFrameworkVersion": "v4.0",
                "phpVersion": "5.6",
                "requestTracingEnabled": false,
                "remoteDebuggingEnabled": false,
                "httpLoggingEnabled": false,
                "logsDirectorySizeLimit": 35,
                "detailedErrorLoggingEnabled": false,
                "publishingUsername": "[concat('$',parameters('sites_etn_qnamaker_name'))]",
                "scmType": "None",
                "use32BitWorkerProcess": true,
                "webSocketsEnabled": false,
                "alwaysOn": false,
                "managedPipelineMode": "Integrated",
                "virtualApplications": [
                    {
                        "virtualPath": "/",
                        "physicalPath": "site\\wwwroot",
                        "preloadEnabled": false
                    }
                ],
                "loadBalancing": "LeastRequests",
                "experiments": {
                    "rampUpRules": []
                },
                "autoHealEnabled": false,
                "cors": {
                    "allowedOrigins": [
                        "*"
                    ],
                    "supportCredentials": false
                },
                "localMySqlEnabled": false,
                "ipSecurityRestrictions": [
                    {
                        "ipAddress": "Any",
                        "action": "Allow",
                        "priority": 1,
                        "name": "Allow all",
                        "description": "Allow all access"
                    }
                ],
                "scmIpSecurityRestrictions": [
                    {
                        "ipAddress": "Any",
                        "action": "Allow",
                        "priority": 1,
                        "name": "Allow all",
                        "description": "Allow all access"
                    }
                ],
                "scmIpSecurityRestrictionsUseMain": false,
                "http20Enabled": false,
                "minTlsVersion": "1.2",
                "ftpsState": "AllAllowed",
                "reservedInstanceCount": 0
            }
        },
        {
            "type": "Microsoft.Web/sites/hostNameBindings",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('sites_etn_qnamaker_name'), '/', parameters('sites_etn_qnamaker_name'), '.azurewebsites.net')]",
            "location": "West US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('sites_etn_qnamaker_name'))]"
            ],
            "properties": {
                "siteName": "[parameters('sites_etn_qnamaker_name')]",
                "hostNameType": "Verified"
            }
        }
    ]
}

这只是我检查的几个网站

编辑:通过 qnamaker.ai 和 API 创建 KB 失败。在 qnamaker.ai 上,我在尝试创建 KB 时收到此消息:

qnamaker.ai 错误信息

这是我用来尝试以编程方式创建它的 PowerShell 脚本:

$body = Get-Content '$(System.DefaultWorkingDirectory)/_AveryCreek_OEM_CSC_Bot/models/qnamaker/Avery_Creek_Commercial_QnA.json' | Out-String

$header = @{
  "Content-Type"="application/json"
  "Ocp-Apim-Subscription-Key"="$(QNA_KEY)"
}

Invoke-RestMethod -Uri "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/create" -Method 'Post' -Body $body -Headers $header

标签: azureazure-devopsazure-resource-managerqnamaker

解决方案


Searching for issues with endpoint keys and qnamaker turns up a fair few results.

I've just closed a case with Azure support for the same issue, and here are some of the steps we checked on the way to fixing this, hopefully one of these will be useful for anyone having this issue in the future as the error message doesn't give you much to go on:

  • First, check the troubleshooting FAQ https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/troubleshooting. There's nothing on the endpoint keys issue, but when you hit something else it's a good starting point.
  • All services - check your naming. For example, for me my search service was named differently than the rest of my config was expecting, and also my cognitive services runtime endpoint in the api-properties was incorrect. Still deployed though - you won't always get an error on the service itself if you provide incorrect names to later created services, you'll just fail at the point of creating your KBs.
  • All services - check your SKUs. While there's no problem that I could find being on free/basic, you can only have 1 qna cognitive service on a free subscription, so you'll need to tear down and recreate or update as you go.
  • QnA cognitive service - config settings (keys and values) are case-sensitive.
  • Qna web app and web app plan - check your quotas haven't been hit, particularly memory and CPU.
  • QnA Web App - You should be able to go the https://{endpoint}/qnamaker/corehealthstatus and see a positive json response like this (or if there's an initException, you've at least got another error to go on):
{"processId":4920,"runtimeVersion":"5.46.0","initException":"","startupTime":"10/28/2020 2:44:39 PM"}
  • Qna Web App - You should also be able to go the https://{endpoint}/qnamaker/proxyhealthstatus and see a positive json response like this.:
{
  "coreVersion": "5.46.0",
  "coreProcessId": 4920,
  "coreUrl": "http://localhost:50061"
}
  • Qna Web App - Don't try to create a KB, whether through the qnamaker portal or dynamically, if your app doesn't show similar successes on those two check endpoints - build a wait if need be. You'll almost certainly see the endpoint errors via the API if you hit it immediately.

For the check endpoints above, the endpoint is visible in the overview section of your web app in the portal, and usually is the name of your app e.g. https://example-app-qnamaker-webapp.azurewebsites.net/qnamaker/corehealthstatus if the app was called example-app-qnamaker-webapp. In my own creation scripts, I checked against coreProcessId > 0 and startupTime is a valid date to indicate service readiness before creating a KB.

EDIT: I'd also add that if it takes a long time to deploy, part of your config is probably wrong. Every time I've had things work correctly, it's been a rapid deployment (and that goes for the services, knowledge bases, and calls to both az cli and the qnamaker REST api).


推荐阅读