作为我们 CI/CD 管道的一部分,我希望使用 PowerShell 向 Azure API 管理注册我们的 Azure 函数应用。从查看文档来看,Import-AzApiManagementApi cmdlet 应该支持此功能,但 -SpecificationFormat 参数中似乎没有用于从现有 Function App 导入的选项。
我确实看到了this feedback article问类似的问题,但目前似乎不可能。
我确实尝试通过 API 定义 Blade 公开 Function App OpenAPI 文档,但这似乎不起作用,因为 Function App 托管在隔离层私有(private)应用程序服务环境中。
有人知道是否有其他选项可以以编程方式将 Function App 导入 APIM 吗?
更新:
我看过AlienCube Function Extensions Github 上的库,它确实可以发布 Swagger API 定义,我可以使用 Import-AzApiManagementApi 来使用它cmdlet,但如果可能的话仍然需要 Azure native 解决方案。
最佳答案
目前似乎不支持此功能,如对 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.
只需通过 Import-AzApiManagementApi 注册新 API 即可实现此目的
Import-AzApiManagementApi -Context $apiMgmtContext -SpecificationFormat OpenApiJson -SpecificationPath [PATH-TO-LOCAL-FILE]' -Path "api" -Protocol Https -ServiceUrl [PATH-TO-FUNCTION-APP-EDNPOINT] | Out-Null
或者使用公开 OpenAPI 定义的 URL
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "OpenApi" -SpecificationUrl [URL-TO-OPENAPI-DEFINITION] -Path "api"
不是一个干净的实现,但它似乎可以工作。
关于azure - 通过Powershell将Function App导入API管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61589965/