You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Bicep编写带API密钥的Azure Form Recognizer API连接?

正确配置Logic App与Azure AI Document Intelligence的API连接(Bicep)

以下是实现Logic App与Azure AI Document Intelligence(原Form Recognizer)API连接的正确Bicep配置,核心是准确匹配API连接的参数要求和认证方式:

param location string = resourceGroup().location
param documentIntelligenceAccountName string
param documentIntelligenceApiKey string

// 引用已存在的Azure AI Document Intelligence实例
resource documentIntelligence 'Microsoft.CognitiveServices/accounts@2023-05-01' existing = {
  name: documentIntelligenceAccountName
}

// 创建formrecognizer类型的API连接
resource formRecognizerConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: 'formrecognizer-connection' // 自定义连接名称
  location: location
  properties: {
    displayName: 'Azure AI Document Intelligence Connection'
    api: {
      // 引用formrecognizer的托管API定义,路径自动匹配当前订阅和区域
      id: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/${location}/managedApis/formrecognizer'
    }
    // 必填参数:API密钥和服务端点
    parameterValues: {
      apiKey: documentIntelligenceApiKey
      endpoint: documentIntelligence.properties.endpoint
    }
    // 指定ApiKey认证方式
    authentication: {
      type: 'ApiKey'
      parameter: {
        name: 'apiKey'
        type: 'string'
        value: documentIntelligenceApiKey
        // 若使用Key Vault存储密钥,可替换value为以下配置(需提前授予连接资源访问密钥权限)
        // keyVaultSecretReference: {
        //   secretName: 'document-intelligence-api-key'
        //   keyVault: {
        //     id: '/subscriptions/<订阅ID>/resourceGroups/<资源组>/providers/Microsoft.KeyVault/vaults/<密钥保管库名称>'
        //   }
        // }
      }
    }
  }
}

关键配置说明

  • API定义引用:必须通过api.id指定formrecognizer的托管API资源路径,确保Logic App识别连接类型。
  • 必填参数:parameterValues中必须同时提供apiKey和endpoint,二者缺一不可,这是formrecognizer连接的硬性要求。
  • 认证方式:明确设置authentication.type为ApiKey,并在parameter中绑定密钥参数名apiKey,确保认证逻辑正确。

常见错误排查

  • 参数名误用:formrecognizer连接仅支持apiKey作为密钥参数名,sharedKey/accountKey等均不适用。
  • 遗漏端点:未配置endpoint会导致连接无法完成服务验证,即使密钥正确也会失败。
  • 认证类型错误:请勿使用其他认证类型(如OAuth),formrecognizer API连接仅支持ApiKey认证。

内容的提问来源于stack exchange,提问作者Andries

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 18:35:06