You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/agents/how-to/tools/openapi-spec.md
+37-29Lines changed: 37 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ services: cognitive-services
6
6
manager: nitinme
7
7
ms.service: azure-ai-agent-service
8
8
ms.topic: how-to
9
-
ms.date: 12/16/2024
9
+
ms.date: 03/12/2025
10
10
author: aahill
11
11
ms.author: aahi
12
12
zone_pivot_groups: selection-function-calling
@@ -25,7 +25,7 @@ OpenAPI Specified tool improves your function calling experience by providing st
25
25
automated, and scalable API integrations that enhance the capabilities and efficiency of your agent.
26
26
[OpenAPI specifications](https://spec.openapis.org/oas/latest.html) provide a formal standard for
27
27
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`.
29
29
30
30
### Usage support
31
31
@@ -41,27 +41,29 @@ work together, generate client code, create tests, apply design standards, and m
41
41
42
42
## Authenticating with API Key
43
43
44
-
With API key authentication type, you can authenticate your OpenAPI spec with various methods such as API key, Bearer token. Please note only one API key security schema is supported per OpenAPI spec. If you need multiple security schemas, please create multiple OpenAPI spec tools.
44
+
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.
45
+
46
+
1. Update your OpenAPI spec security schemas. it has a `securitySchemes` section and one scheme of type `apiKey`. For example:
45
47
46
-
1. Update your OpenAPI spec security schemes: it has `securitySchemes` section and has one scheme of type `apiKey`. For example:
47
48
```json
48
-
"securitySchemes": {
49
-
"apiKeyHeader": {
50
-
"type": "apiKey",
51
-
"name": "x-api-key",
52
-
"in": "header"
53
-
}
54
-
}
49
+
"securitySchemes": {
50
+
"apiKeyHeader": {
51
+
"type": "apiKey",
52
+
"name": "x-api-key",
53
+
"in": "header"
54
+
}
55
+
}
55
56
```
57
+
56
58
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.
57
59
58
-
1. Update your OpenAPI spec to include `security` section:
60
+
1. Update your OpenAPI spec to include a `security` section:
59
61
```json
60
62
"security": [
61
-
{
62
-
"apiKeyHeader": []
63
-
}
64
-
]
63
+
{
64
+
"apiKeyHeader": []
65
+
}
66
+
]
65
67
```
66
68
67
69
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.
@@ -96,31 +98,37 @@ With API key authentication type, you can authenticate your OpenAPI spec with va
96
98
- Connection name: YOUR_CONNECTION_NAME (You will use this connection name in the sample code below.)
97
99
- 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.
98
100
99
-
1. Once you have created a connection, you can use it through SDK or REST API. Please use the tabs above to navigate to your preferred ways of usage.
101
+
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.
100
102
101
-
## Authenticating with Managed Identity (Microsoft Entra ID)
102
-
[Managed Identity (Microsoft Entra ID)](https://learn.microsoft.com/en-us/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.
103
+
## Authenticating with managed identity (Microsoft Entra ID)
104
+
105
+
[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.
103
106
104
107
To set up authenticating with Managed Identity:
108
+
105
109
1. Enable the Azure AI Service of your agent has `system assigned managed identity` enabled.
1. Create a resource of the service you want to connect to through OpenAPI spec
111
+
:::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":::
112
+
113
+
1. Create a resource of the service you want to connect to through OpenAPI spec.
109
114
110
-
1. Assign Azure AI Service proper access to the resource
111
-
1. Click "Access Control" of your resource
115
+
1. Assign proper access to the resource.
116
+
1. Click **Access Control** for your resource
112
117
113
-
1. Click "Add" and then "add role assignement" on the top
118
+
1. Click **Add** and then **add role assignment** at the top of the screen.
119
+
120
+
:::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":::
121
+
122
+
1. Select the proper role assignment needed, usually it will require at least *READER* role. Then click **Next**.
114
123
115
-
1. Select the proper role assignment needed, usually it will require at least READER role. Then click "Next"
124
+
1. Select **Managed identity** and then click **select members**.
116
125
117
-
1. Select "Managed identity" and then click "select members"
126
+
1. In the managed identity dropdown menu, search for **Azure AI services** and then select the AI Service of your agent.
118
127
119
-
1. In the Managed Identity dropdown, search for "Azure AI services" and then select the AI Service of your agent.
128
+
1. Click **Finish**.
120
129
121
-
1. Click "Finish"
130
+
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.
122
131
123
-
1. Once you have it set up, you can use continue creating the tool through SDK or REST API. Please use the tabs above to navigate to your preferred ways of usage.
0 commit comments