Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform
Solved.
This line turns out to be unhelpful. Perhaps not damaging, but in any case not part of the solution:
api_key_connection = client.connections.get("api_list_exemptions_by_subscription")
Since an api key is being used to authenticate, the authentication option is not OpenApiAnonymousAuthDetails(), but instead OpenApiConnectionAuthDetails(...). OpenApiConnectionAuthDetails takes a parameter: security_scheme. The resulting line of code:
auth = OpenApiConnectionAuthDetails(security_scheme=OpenApiConnectionSecurityScheme(connection_id=os.environ["CONNECTION_ID"]))
In this context, the connection_id parameter points to a Foundry connected resource which is of type "Custom Key". The connection_id is an Azure resource id with the following structure:
"/subscriptions/{subscription id}/resourceGroups/{rg name}/providers/Microsoft.CognitiveServices/accounts/{azure ai foundry name}/projects/{project name}/connections/{connected resource name}"
Finally, in the OpenApi spec above, the securityScheme object is at the top level. It should be a child object of the "components" object, as such:
"components": {
"securitySchemes": {
"apiKeyHeader": {
"type": "apiKey",
"name": "x-api-key",
"in": "header"
}
}
},