【问题标题】:Issue with importing Azure Function App in Azure APIM using Swashbuckle使用 Swashbuckle 在 Azure APIM 中导入 Azure Function App 的问题
【发布时间】:2020-10-20 13:58:32
【问题描述】:

我们正在使用 Swashbuckle (v 3.2.2) 为 Azure Function Apps (v3) 生成 Swagger (OpenAPI) 文档。我们可以使用下面的 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

问题是在 APIM 中未使用正确设置导入 Azure 函数应用。导入操作的后端目标类型应为“Azure 资源”,但目标类型设置为“HTTP(s) 端点”。除此之外,我们甚至没有将“Azure Resource”作为选项,而是显示“Azure Logic App”。当我们手动执行时,它会显示正确的后端目标,即“Azure 资源”。详情请参考截图here

我们正在使用 Swashbuckle 版本 3.2.2 Swashbuckle 并将此 link 用于为 Azure Functions 实施 Swagger(OpenAPI)。

【问题讨论】:

    标签: c# azure azure-api-management swashbuckle azure-function-app


    【解决方案1】:

    根据official document,此操作的语法如下:

    $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
    

    尝试跟随它。另外,请确保正确配置了 Open API 文件。

    【讨论】:

      猜你喜欢
      • 2022-08-18
      • 2019-11-16
      • 2023-03-02
      • 2019-07-21
      • 1970-01-01
      • 2022-07-25
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多