【问题标题】:Azure Bicep - Connect Azure API Management (API) to Azure Function AppAzure 二头肌 - 将 Azure API 管理 (API) 连接到 Azure Function App
【发布时间】:2022-02-25 05:40:57
【问题描述】:

我可以在 Azure 管理控制台中看到,特别是在 Azure API 管理服务中,您可以通过 GUI 使用 Azure Functions 来形成 API。

我正在尝试通过 Azure Bicep 实现相同的功能,但在 API Management - API Service 的 Bicep 文档中没有看到任何选项。

在 GUI 中,我看到如下内容:

这允许我指定我的函数应用程序:

但是,在 Bicep 文档中,我没有看到任何我期望的内容:Microsoft.ApiManagement service/apis

我尝试使用Microsoft.ApiManagement service/backends,但这并没有提供相同的体验,而且我还没有设法让它发挥作用。

所以我的问题是,如何将我的 Azure API 管理服务连接到设置为一组 Azure Functions 的 Azure 站点(应用程序)?

【问题讨论】:

    标签: azure azure-functions azure-api-management azure-bicep


    【解决方案1】:

    您需要手动创建后端和所有 api 定义。该门户为您提供了一个很好的创建者,并为您完成所有这些 REST 调用。使用直接在每个资源提供者的 REST 端点上运行的二头肌(和 ARM),您需要构建自己的解决方案。

    也许有一些现有的模板可以做到这一点,但我个人还没有看到。

    【讨论】:

      【解决方案2】:

      我将 OpenAPI 规范添加到我的 functionApps 以生成锯齿机 \ -openAPI 链接(或文件)。然后利用 OpenAPI 文件构建 API。


      // Create APIM Service
      
      resource apimServiceRes 'Microsoft.ApiManagement/service@2021-08-01' = {
        name: 'apim service name'
        location: resourceGroup().location
        sku:{
          capacity: 0
          name: 'select a sku'
        }
        identity:{
          type: 'SystemAssigned'
        }
        properties:{
          publisherName: 'your info'
          publisherEmail: 'your info'
        }
      }
      
      // Create the API Operations with:
      
      resource apimApisRes 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
        name: '${apimServiceRes.name}/name-to-represent-your-api-set'
        properties: {
          format: 'openapi-link'
          value: 'https://link to your swagger file'
          path: ''
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2021-10-20
        • 1970-01-01
        • 2017-07-15
        • 1970-01-01
        • 2020-12-13
        • 2018-01-03
        • 2019-11-16
        • 1970-01-01
        • 2023-02-22
        相关资源
        最近更新 更多