azure - 如何使用 ARM 模板将 azure 函数添加到 API 管理

标签 azure deployment azure-devops azure-functions

我正在使用此 ARM 模板将外部 Azure 函数(已在其他模板中定义)添加到我的 API 管理中,但收到验证错误(资源未在模板中定义)。是否有任何解决方案可以通过 API 管理自动映射 azure 函数?

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {...},
"resources": [

    {
        "apiVersion": "2017-03-01",
        "name": "[parameters('apiManagementServiceName')]",
        "type": "Microsoft.ApiManagement/service",
        "location": "[parameters('location')]",
        "tags": {},
        "sku": {
            "name": "[parameters('sku')]",
            "capacity": "[parameters('skuCount')]"
        },
        "properties": {
            "publisherEmail": "[parameters('publisherEmail')]",
            "publisherName": "[parameters('publisherName')]"
        }
    },
    {
        "type": "Microsoft.ApiManagement/service/apis",
        "apiVersion": "2018-06-01-preview",
        "name": "[concat(parameters('apiManagementServiceName'), '/', parameters('indexerApp'))]",
        "dependsOn": [
            "[resourceId('Microsoft.ApiManagement/service', parameters('apiManagementServiceName'))]",
            "[resourceId(resourceGroup().name, 'Microsoft.Web/sites', parameters('indexerApp'))]"
        ],
        "properties": {
            "displayName": "[parameters('indexerApp')]",
            "apiRevision": "1",
            "description": "Import from \"[parameters('indexerApp')]\" Function App",
            "path": "[parameters('indexerApp')]",
            "protocols": [
                "https"
            ]
        }
    }
]

}

最佳答案

直接链接到逻辑应用程序、函数或其他内部 Azure 资源的资源是 backends (注意复数):

{
  "name": "string",
  "type": "Microsoft.ApiManagement/service/backends",
  "apiVersion": "2019-01-01",
  "properties": {
    "title": "string",
    "description": "string",
    "resourceId": "string",
    "properties": {
      "serviceFabricCluster": {
        "clientCertificatethumbprint": "string",
        "maxPartitionResolutionRetries": "integer",
        "managementEndpoints": [
          "string"
        ],
        "serverCertificateThumbprints": [
          "string"
        ],
        "serverX509Names": [
          {
            "name": "string",
            "issuerCertificateThumbprint": "string"
          }
        ]
      }
    },
    "credentials": {
      "certificate": [
        "string"
      ],
      "query": {},
      "header": {},
      "authorization": {
        "scheme": "string",
        "parameter": "string"
      }
    },
    "proxy": {
      "url": "string",
      "username": "string",
      "password": "string"
    },
    "tls": {
      "validateCertificateChain": "boolean",
      "validateCertificateName": "boolean"
    },
    "url": "string",
    "protocol": "string"
  }
}

相信,如果您指定resourceId属性,Azure基础设施会自动将其他属性连接到您的函数(或逻辑应用)。 “id”的格式并不明显,它需要一个管理URI,其格式为mentioned in this documentation

然后,您可以使用操作的策略将这个创建的后端链接到一个操作 - 这在 ARM 模板中表达起来很困难,但它应该包含一个策略表达式:

<set-backend-service backend-id=\"[name of your backend]\"/>

有关如何将它们链接在一起的示例可以在 this linked sample 中找到。 。它以 Service Fabric 为特色,但它也应该普遍适用于函数。

关于azure - 如何使用 ARM 模板将 azure 函数添加到 API 管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60147438/

相关文章:

windows - 如何从启动任务访问Azure本地存储?

sql-server - 如何在 VSTS 中克隆 SQL Azure 数据库 - 服务器 'A' 中的数据库 'sql01' 和服务器 'B' 中的数据库 'sql01' 已经处于复制关系中

azure - 将 Azure 数据工厂与 InfluxDB 连接

azure - Webhook Ms Graph 监听群组对话

java - 输入授权 token 无法满足请求。(azure-documentdb-java)

c# - 在 C# 中使用 ProtonMail 发送电子邮件

c# - 获取 Silverlight 5 部署路径(在浏览器中以完全信任模式运行时)

c# - 将 WebAPI 部署到外部网站

visual-studio - 无法在 Visual Studio 2013 中打开团队基础构建过程模板

azure - 在 Azure DevOps 中,如何在组织级别而不是项目级别创建 Azure 服务连接?