home / skills / sickn33 / antigravity-awesome-skills / azure-ai-projects-java

azure-ai-projects-java skill

/skills/azure-ai-projects-java

This skill helps Java developers manage Azure AI Foundry projects by coordinating connections, datasets, indexes, and evaluations across sub-clients.

npx playbooks add skill sickn33/antigravity-awesome-skills --skill azure-ai-projects-java

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.7 KB
---
name: azure-ai-projects-java
description: |
  Azure AI Projects SDK for Java. High-level SDK for Azure AI Foundry project management including connections, datasets, indexes, and evaluations.
  Triggers: "AIProjectClient java", "azure ai projects java", "Foundry project java", "ConnectionsClient", "DatasetsClient", "IndexesClient".
package: com.azure:azure-ai-projects
---

# Azure AI Projects SDK for Java

High-level SDK for Azure AI Foundry project management with access to connections, datasets, indexes, and evaluations.

## Installation

```xml
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-ai-projects</artifactId>
    <version>1.0.0-beta.1</version>
</dependency>
```

## Environment Variables

```bash
PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>
```

## Authentication

```java
import com.azure.ai.projects.AIProjectClientBuilder;
import com.azure.identity.DefaultAzureCredentialBuilder;

AIProjectClientBuilder builder = new AIProjectClientBuilder()
    .endpoint(System.getenv("PROJECT_ENDPOINT"))
    .credential(new DefaultAzureCredentialBuilder().build());
```

## Client Hierarchy

The SDK provides multiple sub-clients for different operations:

| Client | Purpose |
|--------|---------|
| `ConnectionsClient` | Enumerate connected Azure resources |
| `DatasetsClient` | Upload documents and manage datasets |
| `DeploymentsClient` | Enumerate AI model deployments |
| `IndexesClient` | Create and manage search indexes |
| `EvaluationsClient` | Run AI model evaluations |
| `EvaluatorsClient` | Manage evaluator configurations |
| `SchedulesClient` | Manage scheduled operations |

```java
// Build sub-clients from builder
ConnectionsClient connectionsClient = builder.buildConnectionsClient();
DatasetsClient datasetsClient = builder.buildDatasetsClient();
DeploymentsClient deploymentsClient = builder.buildDeploymentsClient();
IndexesClient indexesClient = builder.buildIndexesClient();
EvaluationsClient evaluationsClient = builder.buildEvaluationsClient();
```

## Core Operations

### List Connections

```java
import com.azure.ai.projects.models.Connection;
import com.azure.core.http.rest.PagedIterable;

PagedIterable<Connection> connections = connectionsClient.listConnections();
for (Connection connection : connections) {
    System.out.println("Name: " + connection.getName());
    System.out.println("Type: " + connection.getType());
    System.out.println("Credential Type: " + connection.getCredentials().getType());
}
```

### List Indexes

```java
indexesClient.listLatest().forEach(index -> {
    System.out.println("Index name: " + index.getName());
    System.out.println("Version: " + index.getVersion());
    System.out.println("Description: " + index.getDescription());
});
```

### Create or Update Index

```java
import com.azure.ai.projects.models.AzureAISearchIndex;
import com.azure.ai.projects.models.Index;

String indexName = "my-index";
String indexVersion = "1.0";
String searchConnectionName = System.getenv("AI_SEARCH_CONNECTION_NAME");
String searchIndexName = System.getenv("AI_SEARCH_INDEX_NAME");

Index index = indexesClient.createOrUpdate(
    indexName,
    indexVersion,
    new AzureAISearchIndex()
        .setConnectionName(searchConnectionName)
        .setIndexName(searchIndexName)
);

System.out.println("Created index: " + index.getName());
```

### Access OpenAI Evaluations

The SDK exposes OpenAI's official SDK for evaluations:

```java
import com.openai.services.EvalService;

EvalService evalService = evaluationsClient.getOpenAIClient();
// Use OpenAI evaluation APIs directly
```

## Best Practices

1. **Use DefaultAzureCredential** for production authentication
2. **Reuse client builder** to create multiple sub-clients efficiently
3. **Handle pagination** when listing resources with `PagedIterable`
4. **Use environment variables** for connection names and configuration
5. **Check connection types** before accessing credentials

## Error Handling

```java
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceNotFoundException;

try {
    Index index = indexesClient.get(indexName, version);
} catch (ResourceNotFoundException e) {
    System.err.println("Index not found: " + indexName);
} catch (HttpResponseException e) {
    System.err.println("Error: " + e.getResponse().getStatusCode());
}
```

## Reference Links

| Resource | URL |
|----------|-----|
| Product Docs | https://learn.microsoft.com/azure/ai-studio/ |
| API Reference | https://learn.microsoft.com/rest/api/aifoundry/aiprojects/ |
| GitHub Source | https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-projects |
| Samples | https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-projects/src/samples |

Overview

This skill provides a concise guide to the Azure AI Projects SDK for Java, a high-level client for managing Azure AI Foundry projects. It covers authentication, sub-clients (connections, datasets, indexes, evaluations), core operations, and recommended practices for production use. The content is practical and focused on common workflows developers need to integrate project management into Java applications.

How this skill works

The SDK exposes a central AIProjectClientBuilder to configure endpoint and credentials, then builds focused sub-clients such as ConnectionsClient, DatasetsClient, IndexesClient, and EvaluationsClient. Each sub-client offers targeted APIs: enumerate connected resources, upload and manage datasets, create or update search indexes, and run or manage evaluations. The SDK also exposes the OpenAI evaluation client for direct use of evaluation APIs.

When to use it

  • When you need to programmatically list and inspect connected Azure resources for an AI Foundry project.
  • When uploading documents and managing datasets for search or evaluation workflows.
  • When creating, updating, or enumerating search indexes used by your AI workloads.
  • When running or orchestrating model evaluations and integrating OpenAI evaluation APIs.
  • When automating scheduled operations or managing evaluator configurations in a project.

Best practices

  • Use DefaultAzureCredential (or managed identity) for secure, production-ready authentication.
  • Reuse a single AIProjectClientBuilder to create multiple sub-clients to reduce overhead.
  • Handle pagination with PagedIterable when listing resources to avoid missing items.
  • Store endpoints, connection names, and configuration in environment variables, not code.
  • Validate connection and credential types before attempting operations that depend on them.

Example use cases

  • List all Connections to verify which Azure resources (Search, Storage) are bound to a project.
  • Create or update a search index that points to an existing Azure Cognitive Search connection.
  • Upload a batch of documents to a DatasetsClient for downstream indexing and evaluation.
  • Invoke OpenAI evaluation APIs through the evaluations client to run model scoring pipelines.
  • Automate scheduled evaluations or dataset refreshes using the SchedulesClient.

FAQ

How do I authenticate when running locally and in production?

Use DefaultAzureCredential to support local developer flows and managed identities in production. Set PROJECT_ENDPOINT as an environment variable.

Can I access OpenAI evaluation APIs through this SDK?

Yes. The evaluations client exposes the OpenAI EvalService client so you can call OpenAI evaluation APIs directly.