简体   繁体   English

使用 Swashbuckle 在 Azure APIM 中导入 Azure Function App 的问题

[英]Issue with importing Azure Function App in Azure APIM using Swashbuckle

We are using Swashbuckle (v 3.2.2) to generate Swagger (OpenAPI) document for Azure Function Apps (v3).我们正在使用 Swashbuckle (v 3.2.2) 为 Azure Function Apps (v3) 生成 Swagger (OpenAPI) 文档。 We are able to import Azure Function App in APIM using below PowerShell script:我们可以使用以下 PowerShell 脚本在 APIM 中导入 Azure Function App:

 $specificationUrl="https://myfunctionapp.azurewebsites.net/api/swagger/json?code=tdkaksas8393dkkfkr04kfkkfkf9933kk9==" $apiContext = New-AzApiManagementContext -ResourceGroupName "MyResourceGroup" -ServiceName "MyServiceName" Import-AzApiManagementApi -Context $apiContext -SpecificationFormat "OpenApi" -SpecificationUrl $specificationUrl -Path apis

The issue is Azure function app is not getting imported with correct setting in APIM.问题是 Azure 函数应用程序未通过 APIM 中的正确设置导入。 Imported operation's Backend Target type should be "Azure Resource" but Target type getting set to "HTTP(s) endpoint".导入操作的后端目标类型应为“Azure Resource”,但目标类型设置为“HTTP(s) 端点”。 Apart from this we are even not getting "Azure Resource" as option instead it shows "Azure Logic App".除此之外,我们甚至没有获得“Azure Resource”作为选项,而是显示“Azure Logic App”。 When we do manually it shows correct Backend Target ie "Azure Resource".当我们手动执行时,它会显示正确的后端目标,即“Azure 资源”。 Pls refer screenshot here for details.请参阅此处的屏幕截图了解详细信息。

We are using Swashbuckle version 3.2.2 Swashbuckle and referred this link for implementation of Swagger(OpenAPI) for Azure Functions.我们正在使用 Swashbuckle 版本 3.2.2 Swashbuckle并参考此链接为 Azure Functions 实现 Swagger(OpenAPI)。

As per official document , below is the syntax for this operation:根据官方文档,以下是此操作的语法:

$context = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $context -SpecificationFormat OpenApi -SpecificationUrl https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml -Path "petstore30"

ApiId                         : af3f57bab399455aa875d7050654e9d1
Name                          : Swagger Petstore
Description                   :
ServiceUrl                    : http://petstore.swagger.io/v1
Path                          : petstore30
ApiType                       : http
Protocols                     : {Https}
AuthorizationServerId         :
AuthorizationScope            :
OpenidProviderId              :
BearerTokenSendingMethod      : {}
SubscriptionKeyHeaderName     : Ocp-Apim-Subscription-Key
SubscriptionKeyQueryParamName : subscription-key
ApiRevision                   : 1
ApiVersion                    :
IsCurrent                     : True
IsOnline                      : False
SubscriptionRequired          :
ApiRevisionDescription        :
ApiVersionSetDescription      :
ApiVersionSetId               :
Id                            : /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso/apis/af3f57bab399455aa875d7050654e9d1     
ResourceGroupName             : Api-Default-West-US
ServiceName                   : contoso

Try following it.尝试跟随它。 Also, make sure that Open API file is correctly configured.另外,请确保正确配置了 Open API 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM