azure - 通过Powershell将Function App导入API管理

标签 azure powershell azure-api-management azure-function-app

作为我们 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/

相关文章:

powershell - 融合应用程序 Azure AD v2,以编程方式注册

Powershell Invoke-Item 不再适用于在资源管理器中打开目录

powershell - Env : and [System. Environment] 有什么区别?

基于路径参数的 Azure API 管理响应缓存

azure apim 导入策略 - 字 rune 字中的字符过多

azure - Azure APIM 中后端服务 URL 和 Web 服务 URL 之间的区别

python - 适用于 Python 的 Azure ADAL - 模型没有属性 'acquire_token_with_username_password'

api - 无法弄清楚如何查询 Bing/Azure Marketplace API

javascript - 尝试使 hmac-sha256 与适用于 Canvas API 的 Powershell 一起使用

odata - OData 的 Azure API 管理问题