简体   繁体   English

Azure Bicep - 将 Azure API 管理 (API) 连接到 Azure Function App

[英]Azure Bicep - Connect Azure API Management (API) to Azure Function App

I can see within the Azure Management Console, specifically within the Azure API Management Service, via the GUI you are able to use Azure Functions to form an API.我可以在 Azure 管理控制台中看到,特别是在 Azure API 管理服务中,通过 GUI,您可以使用 Azure 功能来形成 API。

I am trying to implement the same via Azure Bicep, but I do not see any options in the Bicep documentation for API Management - API Service .我正在尝试通过 Azure Bicep 实现相同的功能,但我在 Bicep 文档中没有看到API Management - API Service的任何选项。

In the GUI, I see something like this:在 GUI 中,我看到类似这样的内容:

Azure API GUI - 连接到 Azure 函数

This allows me to specify my Function App:这允许我指定我的 Function 应用程序:

选择 Azure Functions 应用

However, within the Bicep Documentation, I don't see anything where I would expect to: Microsoft.ApiManagement service/apis但是,在 Bicep 文档中,我没有看到我期望的任何内容: Microsoft.ApiManagement service/apis

I have instead tried using the Microsoft.ApiManagement service/backends but that doesn't give the same experience and I haven't managed to get that to work.相反,我尝试使用Microsoft.ApiManagement 服务/后端,但这并没有提供相同的体验,而且我还没有设法让它发挥作用。

So my question is, how do I connect my Azure API Management service to an Azure Site (app) which is set as a suite of Azure Functions?所以我的问题是,如何将我的 Azure API 管理服务连接到设置为一套 Azure 功能的 Azure 站点(应用程序)?

You need to create backend and all api definitions manually.您需要手动创建后端和所有 api 定义。 The portal gives you a nice creator and does all those REST calls for you.该门户网站为您提供了一个不错的创建者,并为您完成所有这些 REST 呼叫。 With bicep (and ARM) which is operating directly on the REST endpoints of each resource provider you need to build own solution.使用直接在每个资源提供者的 REST 端点上运行的 bicep(和 ARM),您需要构建自己的解决方案。

Perhaps there're somewhere some existing templates that can do this but personally I didn't see any yet.也许在某个地方有一些现有的模板可以做到这一点,但我个人还没有看到。

I added OpenAPI specifications to my functionApps to produce the sawgger \ -openAPI link (or file).我将 OpenAPI 规范添加到我的 functionApps 以生成 sawgger \ -openAPI 链接(或文件)。 Then leveraged the OpenAPI file to build the APIs.然后利用 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: ''
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM