Uksh
Uksh

Reputation: 11

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). We are able to import Azure Function App in APIM using below PowerShell script:

$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. Imported operation's Backend Target type should be "Azure Resource" but Target type getting set to "HTTP(s) endpoint". Apart from this we are even not getting "Azure Resource" as option instead it shows "Azure Logic App". When we do manually it shows correct Backend Target i.e. "Azure Resource". 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.

Upvotes: 0

Views: 427

Answers (1)

Harshita Singh
Harshita Singh

Reputation: 4870

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.

Upvotes: 0

Related Questions