azure - How to write a Bicep API Connection formrecognizer with api key - Stack Overflow

admin2025-04-19  5

I am trying to write a bicep part for an Azure Logic App API connection to an Azure AI Document Intelligence instance. This connection can be made with type formrecognizer.

I have searched the web to find how the bicep file should be written, but everthing I've tried failed so far. Even Co-pilot had no answer that worked. This is what I have:

resource documentIntelligenceConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: documentIntelligenceConnectionName
  location: location
  kind: 'V1'
  properties: {
    displayName: documentIntelligence.name
    api: {
      id: subscriptionResourceId('Microsoft.Web/locations/managedApis', location, 'formrecognizer')
    }
    nonSecretParameterValues: {
      siteUrl: documentIntelligence.properties.endpoint
    }
    parameterValues: {
      apiKey: documentIntelligence.listKeys().key1
    }
  }
}

But this doesn't work:

parameterValues: {
  apiKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  sharedKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  accountKey: documentIntelligence.listKeys().key1
}

or this

secureParameterValues: {
  sharedKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  auth: {
    type: 'ApiKey'
    apiKey: documentIntelligence.listKeys().key1
  }
}

Does anyone know the correct way to add the apikey with bicep to a formrecognizer API connection?

I am trying to write a bicep part for an Azure Logic App API connection to an Azure AI Document Intelligence instance. This connection can be made with type formrecognizer.

I have searched the web to find how the bicep file should be written, but everthing I've tried failed so far. Even Co-pilot had no answer that worked. This is what I have:

resource documentIntelligenceConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: documentIntelligenceConnectionName
  location: location
  kind: 'V1'
  properties: {
    displayName: documentIntelligence.name
    api: {
      id: subscriptionResourceId('Microsoft.Web/locations/managedApis', location, 'formrecognizer')
    }
    nonSecretParameterValues: {
      siteUrl: documentIntelligence.properties.endpoint
    }
    parameterValues: {
      apiKey: documentIntelligence.listKeys().key1
    }
  }
}

But this doesn't work:

parameterValues: {
  apiKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  sharedKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  accountKey: documentIntelligence.listKeys().key1
}

or this

secureParameterValues: {
  sharedKey: documentIntelligence.listKeys().key1
}

or this

parameterValues: {
  auth: {
    type: 'ApiKey'
    apiKey: documentIntelligence.listKeys().key1
  }
}

Does anyone know the correct way to add the apikey with bicep to a formrecognizer API connection?

Share Improve this question edited Jan 28 at 9:21 Thomas 30.1k6 gold badges98 silver badges141 bronze badges Recognized by Microsoft Azure Collective asked Jan 27 at 9:43 AndriesAndries 2253 silver badges12 bronze badges 2
  • Is it throwing any error! @Andries – Jahnavi Commented Jan 27 at 11:24
  • 1 Yes. At deployment time. I.e. - Details:errorCode: ParameterNotDefined. Message: Parameter 'auth' is not allowed on the connection since it was not defined as a connection parameter when the API was registered. – Andries Commented Jan 27 at 11:55
Add a comment  | 

1 Answer 1

Reset to default 0

Easiest way to figure this out is to open developer tools in your browser, create the connection manually and look at the request sent from the portal in the network tab. This worked for me:

resource documentIntelligenceConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: documentIntelligenceConnectionName
  location: location
  kind: 'V1'
  properties: {
    displayName: documentIntelligence.name
    api: {
      id: subscriptionResourceId('Microsoft.Web/locations/managedApis', location, 'formrecognizer')
    }
    parameterValues: {
      api_key: documentIntelligence.listKeys().key1
      siteUrl: documentIntelligence.properties.endpoint      
    }
  }
}
转载请注明原文地址:http://anycun.com/QandA/1745042911a90356.html