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
To complete this tutorial, you need an Azure AI Agent project and a RESTful API hosted on Azure App Service. The API should have an OpenAPI specification that defines the API. The OpenAPI specification for the sample app in this tutorial is provided.
19
19
20
20
1. Ensure you complete the prerequisites and setup steps in the [quickstart](/azure/ai-services/agents/quickstart.md). This quickstart walks you through creating your Azure AI Hub and Agent project. You can also complete the agent configuration and sample the quickstart provides to get a full understanding of the tool and ensure your setup works.
21
-
1.Ensure you complete the [RESTful API tutorial](./app-service-web-tutorial-rest-api.md) in Azure App Service. You don't need to complete the part of the tutorial where CORS functionality is added. This tutorial walks you through creating a to-do list app.
21
+
1.Follow the guidance to create the sample app and deploy it to Azure App Service. The sample app is a simple to-do list API that allows you to create, read, update, and delete items from the list.
22
22
23
+
## Create and deploy the sample app
24
+
25
+
1. Ensure you have the [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed and that you're logged into your Azure account. You can sign-in using the following command.
26
+
27
+
```bash
28
+
az login
29
+
```
30
+
31
+
1. Ensure you have [Git installed](https://git-scm.com/downloads).
32
+
1. Ensure you have the latest [.NET 9.0 SDK installed](https://dotnet.microsoft.com/download/dotnet/9.0).
33
+
1. In the terminal window, use `cd` to go to a working directory.
34
+
1. Clone the sample repository, and then go to the repository root. This repository contains an app based on the tutorial [ASP.NET Core web API documentation with Swagger / OpenAPI](/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio). It uses a Swagger generator to serve the [Swagger UI](https://swagger.io/swagger-ui/) and the Swagger JSON endpoint.
1. You can run the app locally to ensure it works. To start the app, run the following commands.
42
+
43
+
```bash
44
+
dotnet restore
45
+
dotnet run
46
+
```
47
+
48
+
1. Navigate to `http://localhost:5000/swagger` in a browser to try the Swagger UI.
49
+
1. Navigate to `http://localhost:5000/api/todo` to see a list of ToDo JSON items.
50
+
1. To stop the app, press `Ctrl+C` in the terminal window.
51
+
1. To deploy the app to Azure App Service, run the following command.
52
+
53
+
```bash
54
+
az webapp up
55
+
```
56
+
57
+
1. After the app is deployed, navigate to the URL provided in the terminal window to see the app running in Azure App Service. It can take a few minutes for the app to be fully deployed and running. Note this URL for later use.
58
+
23
59
## Connect your AI Agent to your App Service API
24
60
25
61
### Create and review the OpenAPI specification
26
62
27
63
Now that you have the required infrastructure, you can put it all together and start interacting with your API using your AI Agent. For a general overview on how to do get started, see [How to use Azure AI Agent Service with OpenAPI Specified Tools](/azure/ai-services/agents/how-to/tools/openapi-spec.md). That overview includes prerequisites and other requirements including how to include authentication if your API requires it. The provided sample API is publicly accessible so authentication isn't required.
28
64
29
-
1.The following specification is the OpenAPI specification for the sample app that is provided. On your local machine, create a file called `swagger.json` and copy the following contents.
65
+
1.This specification is the OpenAPI specification for the sample app that is provided. On your local machine, create a file called `swagger.json` and copy the following contents.
30
66
31
67
```json
32
68
{
@@ -37,7 +73,7 @@ Now that you have the required infrastructure, you can put it all together and s
@@ -279,7 +315,8 @@ Now that you have the required infrastructure, you can put it all together and s
279
315
}
280
316
```
281
317
282
-
1. Review the file to understand the API and its endpoints. The `operationId` values are CRUD operations that can be performed on the to-do list. Once the app is up and running, you can use your AI Agent to invoke the API and perform the various operations on your behalf using natural language. At the end of the specification, you have the `security` section. This section is where you add authentication if your API requires it. This section is left blank for the sample app, but is included because the AI Agent Service requires it.
318
+
1. Replace the placeholder for `APP_SERVICE_URL` with your app's URL that you copied earlier. This URL is in the format `https://<app_name>.azurewebsites.net`.
319
+
1. Review the file to understand the API and its endpoints. The `operationId` values are CRUD operations that can be performed on the to-do list. Once the app is up and running, you can use your AI Agent to invoke the API and perform the various operations on your behalf using natural language. At the end of the specification, you have the `securitySchemes` section. This security section is where you add authentication if your API requires it. This section is left blank for the sample app, but is included because the AI Agent Service requires it.
283
320
284
321
### Create the OpenAPI Spec tool definition
285
322
@@ -358,15 +395,15 @@ Now that you have the required infrastructure, you can put it all together and s
358
395
print("Deleted agent")
359
396
```
360
397
361
-
1. Replace the placeholder for your project's connection string. If you need help with this step, see the [Configure and run agent section of the quickstart](/azure/ai-services/agents/quickstart.md#configure-and-run-agent) for details on how to get your connection string.
362
-
1. Review the file to understand how the OpenAPI tool is created and how the AI Agent is invoked. Each time time the tool is invoked, the AI Agent will use the OpenAPI specification to determine how to interact with the API. The OpenAPI specification is passed into the file. The `message_content` variable is where you enter the natural language command that you want the AI Agent to perform. You're prompted to enter the message once you run the script. The AI Agent will then invoke the API and return the results. It will create and delete the AI Agent each time you run the script.
398
+
1. Replace the placeholder for your project's connection string. If you need help with finding the connection string, see the [Configure and run agent section of the quickstart](/azure/ai-services/agents/quickstart.md#configure-and-run-agent) for details on how to get your connection string.
399
+
1. Review the file to understand how the OpenAPI tool is created and how the AI Agent is invoked. Each time the tool is invoked, the AI Agent uses the OpenAPI specification to determine how to interact with the API. The OpenAPI specification is passed into the file. The `message_content` variable is where you enter the natural language command that you want the AI Agent to perform. You're prompted to enter the message once you run the script. The AI Agent invokes the API and returns the results. It creates and deletes the AI Agent each time you run the script.
363
400
364
401
## Run the OpenAPI Spec tool
365
402
366
-
1. Open a terminal and navigate to the directory where you created the `tool.py` and `swagger.json` files. Run the following command to run the script.
403
+
1. Open a terminal and navigate to the directory where you created the `tool.py` and `swagger.json` files. To run the script, run the following command.
367
404
368
405
```bash
369
406
python tool.py
370
407
```
371
408
372
-
1. When prompted, enter a message for your Agent. For example, you can enter "What's on my to-do list?", "Add a task to buy bread", "Mark all my tasks as done", or any other question or action that can be performed on the list. The AI Agent then invokes the API and returns the results. You can also enter `Add an item to the to do list` and the AI Agent prompts you for the details of the item to add.
409
+
1. When prompted, enter a message for your Agent. For example, you can enter "What's on my to-do list?", "Add a task to buy bread," "Mark all my tasks as done," or any other question or action that can be performed on the list. The AI Agent then invokes the API and returns the results. You can also enter `Add an item to the to do list` and the AI Agent prompts you for the details of the item to add.
0 commit comments