gpt4 book ai didi

发布到 Marketplace 的 Azure 托管应用程序无法向自定义提供程序发出 POST 请求(由于 swagger 被阻止?)

转载 作者:行者123 更新时间:2023-12-02 07:20:26 25 4
gpt4 key购买 nike

我有一个托管应用程序,其中包含一个按钮,该按钮调用对底层自定义资源提供程序的 POST 请求。我已使用订阅中的服务目录部署了此托管应用程序,并且它可以正常工作。但是,当我将托管应用程序发布到 Azure 市场并提交时,它需要通过 github 原始 URI 托管和链接一个 swagger 定义。

我的 json 格式的 swagger 定义:

    {
"swagger": "2.0",
"info": {
"title": "Azure Functions Open API Extension",
"version": "2018-09-01-preview"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"security": [
{}
],
"securityDefinitions": {},
"paths": {
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{minirpname}/TransitionAccount": {
"post": {
"tags": [
"PostTransitionAccount"
],
"operationId": "PostTransitionAccount",
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"name": "api-version",
"description": "api-version is required. Valid versions are 2018-09-01-preview",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "subscriptionId",
"description": "This is the Id of the subscription",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "resourceGroupName",
"description": "This is the resource group name where the managed app is deployed",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "minirpname",
"description": "This is the resource provider name",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "The OK response",
"schema": {}
},
"500": {
"description": "The InternalServerError response",
"schema": {}
}
}
}
}
},
"parameters": {
"ApiVersionParameter": {
"name": "api-version",
"in": "query",
"required": true,
"type": "string",
"description": "Client Api Version."
}
}
}

Marketplace 在发布时采用并验证此 swagger 定义,但是当我通过 Marketplace 部署托管应用程序并单击按钮时,我收到错误。

enter image description here

错误消息显示“请检查 swagger 验证是否为此操作定义了路由。”

这是我的自定义资源提供程序中的路径定义。

{
"apiVersion": "[variables('customrpApiversion')]",
"type": "Microsoft.CustomProviders/resourceProviders",
"name": "[parameters('providerName')]",
"location": "[parameters('location')]",
"properties": {
"actions": [
{
"name": "transitionAccount",
"routingType": "Proxy",
"endpoint": "[concat('https://', variables('funcname'), '.azurewebsites.net/api/{requestPath}')]"
}
],
"resourceTypes": [
{
"name": "accountType",
"routingType": "Proxy,Cache",
"endpoint": "[concat('https://', variables('funcname'), '.azurewebsites.net/api/{requestPath}')]"
}
],
"Validations" :[
{
"ValidationType": "swagger",
"Specification": "https://raw.githubusercontent.com/cleardataeng/azure-shared-image-gallery-syncer/master/metadata/account-type-swagger.json"
},
{
"ValidationType": "swagger",
"Specification": "https://raw.githubusercontent.com/cleardataeng/azure-shared-image-gallery-syncer/master/metadata/transition-account-swagger.json"
}
]
},
"dependsOn": [
"[concat('Microsoft.Web/sites/',variables('funcname'))]"
],
"resources": [
{
"type": "accountType",
"name": "current",
"apiVersion": "[variables('customrpApiversion')]",
"location": "[parameters('location')]",
"properties": {
"displayName": "[subscription().displayName]",
"tenantId": "[subscription().tenantId]",
"subscriptionId": "[subscription().subscriptionId]",
"accountType": "Evaluation",
"accountTypeStatus": "Pending"
},
"dependsOn": [
"[concat('Microsoft.CustomProviders/resourceProviders/',parameters('providerName'))]"
]
}
]
}

当我提供了在发布期间经过验证的 swagger 定义文档时,为什么我在 Marketplace 部署的应用程序中单击转换帐户按钮时会收到错误消息?

编辑:事件日志中的错误如下。从事件日志中提取的错误如下。 {“错误”:{“代码”:“MissingSwagger”,“消息”:“找不到请求的有效swagger定义'/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/mrg-xxxxxx-management- appli-20210526184240/providers/Microsoft.CustomProviders/resourceProviders/public/transitionAccount',方法为“POST”。请检查 swagger 验证是否为此操作定义了路由。"}}

最佳答案

该问题与 swagger 比较的区分大小写性质有关。在使用大小写更改更新 swagger 文件后,您需要重新创建自定义 rp。原因是我们在创建自定义提供程序资源期间缓存了 swagger 文件,并且不会知道已发生更新。

目前,我们刚刚完成了一项部署,使 swaggers 成为市场优惠的 optional 。请在不指定验证部分的情况下重试您的部署,这应该可以正常工作。

关于发布到 Marketplace 的 Azure 托管应用程序无法向自定义提供程序发出 POST 请求(由于 swagger 被阻止?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67627195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com