首页 > 解决方案 > Importing Function App in to API Management via Powershell

问题描述

As part of our CI/CD pipeline I am looking to register our Azure Function Apps with Azure API Management using PowerShell. From looking at the documentation it appears that the Import-AzApiManagementApi cmdlet should support this but there does not appear to be on option in the -SpecificationFormat parameter to import from an existing Function App.

I did see this feedback article asking a similar question but it does not appear to be possible at this time.

I did try to expose the Function App OpenAPI documentation via the API Definition blade but that does not appear to work as the Function App is hosted within an Isolated tier private Application Service Environment.

Anyone any idea if there is another option to programatically import a Function App into APIM?

Update:

I have looked at the AlienCube Function Extensions library on Github and it does enable the publication of Swagger API definition which I can consume with the Import-AzApiManagementApi cmdlet but still want an Azure native solution if possible.

标签: azurepowershellazure-api-managementazure-function-app

解决方案


Looks like this functionality is not supported at the moment as described in the response to theis GitHub issue.

I have reached out to the APIM team internally regarding this issue and received confirmation that there isn't a backend endpoint available for this operation at this time around (Portal does it with Javascript on the frontend hence the 22 calls).

As the next step, please consider submitting a feature request on the Azure UserVoice (or upvote an existing one if it exists) for the APIM team to review its priority for the product roadmap.

It is possible to achieve this by just registering the new API via Import-AzApiManagementApi

Import-AzApiManagementApi -Context $apiMgmtContext -SpecificationFormat OpenApiJson -SpecificationPath [PATH-TO-LOCAL-FILE]' -Path "api" -Protocol Https -ServiceUrl [PATH-TO-FUNCTION-APP-EDNPOINT] | Out-Null

Or using a URL that exposes an OpenAPI definition

Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "OpenApi" -SpecificationUrl [URL-TO-OPENAPI-DEFINITION] -Path "api"

Not a clean implementation but it appears to work.


推荐阅读