Skip to content

Commit e33b19c

Browse files
authored
Merge pull request #3423 from lindazqli/patch-27
Update openapi-spec.md
2 parents 31f535c + 785f593 commit e33b19c

File tree

3 files changed

+58
-13
lines changed

3 files changed

+58
-13
lines changed

articles/ai-services/agents/how-to/tools/openapi-spec.md

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
88
ms.topic: how-to
9-
ms.date: 12/16/2024
9+
ms.date: 03/12/2025
1010
author: aahill
1111
ms.author: aahi
1212
zone_pivot_groups: selection-function-calling
@@ -25,7 +25,7 @@ OpenAPI Specified tool improves your function calling experience by providing st
2525
automated, and scalable API integrations that enhance the capabilities and efficiency of your agent.
2626
[OpenAPI specifications](https://spec.openapis.org/oas/latest.html) provide a formal standard for
2727
describing HTTP APIs. This allows people to understand how an API works, how a sequence of APIs
28-
work together, generate client code, create tests, apply design standards, and more. Currently, we support 3 authentication types with the OpenAPI 3.0 specified tools: `anonymous`, `API key`, `managed identity`.
28+
work together, generate client code, create tests, apply design standards, and more. Currently, we support three authentication types with the OpenAPI 3.0 specified tools: `anonymous`, `API key`, `managed identity`.
2929

3030
### Usage support
3131

@@ -42,17 +42,30 @@ work together, generate client code, create tests, apply design standards, and m
4242

4343
## Authenticating with API Key
4444

45-
1. Verify that the OpenAPI spec supports API keys: it has `securitySchemes` section and has one scheme of type `apiKey`. For example:
45+
With API key authentication, you can authenticate your OpenAPI spec using various methods such as an API key or Bearer token. Only one API key security schema is supported per OpenAPI spec. If you need multiple security schemas, create multiple OpenAPI spec tools.
46+
47+
1. Update your OpenAPI spec security schemas. it has a `securitySchemes` section and one scheme of type `apiKey`. For example:
48+
4649
```json
47-
"securitySchemes": {
48-
"apiKeyHeader": {
49-
"type": "apiKey",
50-
"name": "x-api-key",
51-
"in": "header"
52-
}
53-
}
50+
"securitySchemes": {
51+
"apiKeyHeader": {
52+
"type": "apiKey",
53+
"name": "x-api-key",
54+
"in": "header"
55+
}
56+
}
57+
```
58+
59+
You usually only need to update the `name` field, which corresponds to the name of `key` in the connection. If the security schemes include multiple schemes, we recommend keeping only one of them.
60+
61+
1. Update your OpenAPI spec to include a `security` section:
62+
```json
63+
"security": [
64+
{
65+
"apiKeyHeader": []
66+
}
67+
]
5468
```
55-
If the security schemes include multiple schemes, we recommend keeping only one of them.
5669

5770
1. Remove any parameter in the OpenAPI spec that needs API key, because API key will be stored and passed through a connection, as described later in this article.
5871

@@ -72,7 +85,7 @@ work together, generate client code, create tests, apply design standards, and m
7285
:::image type="content" source="../../media/tools/bing/api-key-connection.png" alt-text="A screenshot of the custom keys selection for the AI project." lightbox="../../media/tools/bing/api-key-connection.png":::
7386

7487
1. Enter the following information
75-
- key: `name` of your security scheme. In this example, it should be `x-api-key`
88+
- key: `name` field of your security scheme. In this example, it should be `x-api-key`
7689
```json
7790
"securitySchemes": {
7891
"apiKeyHeader": {
@@ -85,9 +98,41 @@ work together, generate client code, create tests, apply design standards, and m
8598
- value: YOUR_API_KEY
8699
- Connection name: YOUR_CONNECTION_NAME (You will use this connection name in the sample code below.)
87100
- Access: you can choose either *this project only* or *shared to all projects*. Just make sure in the sample code below, the project you entered connection string for has access to this connection.
88-
101+
102+
1. Once you have created a connection, you can use it through the SDK or REST API. Use the tabs at the top of this article to see code examples.
103+
104+
## Authenticating with managed identity (Microsoft Entra ID)
105+
106+
[Microsoft Entra ID](/entra/fundamentals/whatis) is a cloud-based identity and access management service that your employees can use to access external resources. Microsoft Entra ID allows you to authenticate your APIs with additional security without the need to pass in API keys. Once you have set up managed identity authentication, it will authenticate through the Azure AI Service your agent is using.
107+
108+
To set up authenticating with Managed Identity:
109+
110+
1. Enable the Azure AI Service of your agent has `system assigned managed identity` enabled.
111+
112+
:::image type="content" source="../../media/tools/managed-identity-portal.png" alt-text="A screenshot showing the managed identity selector in the Azure portal." lightbox="../../media/tools/managed-identity-portal.png":::
113+
114+
1. Create a resource of the service you want to connect to through OpenAPI spec.
115+
116+
1. Assign proper access to the resource.
117+
1. Click **Access Control** for your resource
118+
119+
1. Click **Add** and then **add role assignment** at the top of the screen.
120+
121+
:::image type="content" source="../../media/tools/role-assignment-portal.png" alt-text="A screenshot showing the role assignment selector in the Azure portal." lightbox="../../media/tools/role-assignment-portal.png":::
122+
123+
1. Select the proper role assignment needed, usually it will require at least *READER* role. Then click **Next**.
124+
125+
1. Select **Managed identity** and then click **select members**.
126+
127+
1. In the managed identity dropdown menu, search for **Azure AI services** and then select the AI Service of your agent.
128+
129+
1. Click **Finish**.
130+
131+
1. Once the setup is done, you can continue by using the tool through the SDK or REST API. Use the tabs at the top of this article to see code samples.
132+
89133
::: zone-end
90134

135+
91136
::: zone pivot="code-example"
92137
## Step 1: Create a project client
93138
Create a client object, which will contain the connection string for connecting to your AI project and other resources.
71.7 KB
Loading
107 KB
Loading

0 commit comments

Comments
 (0)