azure - 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.
解决方案
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.
推荐阅读
- python - python数据结构查找跨越给定时间点的窗口
- php - 为什么我的 API 需要 2-3 秒来处理一个请求?
- go - 如何修复golang中的竞争条件?
- react-native - 如何使用 Xcode 12 Beta 4 构建 React-Native 项目?
- python - 手动触发 PyQt/PySide 内存错误?
- javascript - javascript 找到 45-45-90 三角形的第三个点给定 2 个点
- javascript - 有没有办法将日期格式从 date.toLocaleString() 转换为 UTC 格式?
- node.js - NodeJS:默认服务器的端口是什么?
- c# - 使用 EF Core + Code First + 迁移创建数据库
- javascript - 使用反应挂钩 setState 更改数组中的变量