Skip to content

Installing the AI Foundry SDK

This guide will walk you through the process of installing and setting up the Azure AI Foundry development environment.

Prerequisites

  • Python 3.8 or later
  • pip (Python package manager)
  • Azure subscription with access to Azure AI services
  • Azure CLI (recommended for authentication)

Required Components

  1. Core SDKs
  2. Azure AI Resources SDK for project and model management
  3. Azure AI Evaluation SDK for performance assessment
  4. Azure Identity package for authentication

  5. Optional Components

  6. Azure Storage SDK for data management
  7. Azure KeyVault SDK for secure credential storage
  8. Azure AI Inference SDK with OpenTelemetry for model interaction and tracing

Environment Setup

  1. Create a Virtual Environment (Recommended)
# Create a new virtual environment
python -m venv .venv

# Activate the virtual environment (Linux/Mac)
source .venv/bin/activate

# Activate the virtual environment (Windows)
.\.venv\Scripts\activate
  1. Install Required Packages
# Install core Azure AI Foundry packages
pip install azure-ai-projects
pip install azure-ai-inference
pip install azure-ai-evaluation
pip install azure-ai-contentsafety
pip install azure-monitor-opentelemetry
pip install azure-identity

# Optional but recommended packages
pip install azure-storage-blob  # For data storage
pip install azure-keyvault-secrets  # For secure credential management
  1. Configure Development Environment

```python

config.py

import os from azure.identity import DefaultAzureCredential from azure.ai.resources import AIProjectClient

def setup_environment(): """Configure the development environment with required settings.""" try: # Initialize Azure credentials credential = DefaultAzureCredential()

    # Create AI Project client
    client = AIProjectClient(
        subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
        resource_group=os.getenv("AZURE_RESOURCE_GROUP"),
        credential=credential
    )

    return client
except Exception as e:
    print(f"Error setting up environment: {str(e)}")
    raise

Example usage

if name == "main": # Set required environment variables os.environ["AZURE_SUBSCRIPTION_ID"] = "your-subscription-id" os.environ["AZURE_RESOURCE_GROUP"] = "your-resource-group"

# Initialize the client
client = setup_environment()
print("Environment setup completed successfully")

Development Tools Integration

  1. IDE Support
  2. Visual Studio Code
  3. PyCharm
  4. Jupyter Notebooks

  5. Version Control

  6. Git integration
  7. Project structure
  8. Dependency management

Best Practices

  • Use virtual environments
  • Keep dependencies updated
  • Follow security guidelines
  • Implement proper error handling

Troubleshooting Guide

  1. Common Issues
  2. Package version conflicts
  3. Authentication failures
  4. Environment configuration

  5. Resolution Steps

  6. Verify Python version
  7. Check package compatibility
  8. Validate credentials
  9. Review environment setup

Next: Setting up Authentication