genaiops-azureaisdk-template

Local Environment Setup with Conda

Prerequisites

Step 1: Using Conda Environment Manager

You can use Conda for managing your Python environment. This guide will focus on Conda setup.

Conda Environment Setup

# Create a new conda environment with Python 3.9
conda create -n myenv python=3.9

# Activate the environment
conda activate myenv

Step 2: Azure Authentication

# Login to Azure
az login

# Verify your login
az account show

Step 3: Install Required Packages

# Install execution requirements
python -m pip install -r ./.github/requirements/execute_job_requirements.txt

# Install validation requirements
python -m pip install -r ./.github/requirements/build_validation_requirements.txt

# Install the package in editable mode
python -m pip install -e .

Step 4: Environment Configuration

Create and configure your environment file:

# Create .env file from template
cp .env.sample .env

Environment Variables Configuration

Variable Description Where to Find
AZURE_OPENAI_API_VERSION Azure OpenAI API version Use the latest stable version from Azure OpenAI documentation e.g. 2024-02-15-preview
AZURE_AI_CHAT_ENDPOINT Azure OpenAI Chat API endpoint Found in Azure Portal → Azure OpenAI resource → Keys and Endpoint. e.g. https://your-resource.openai.azure.com/openai/deployments/your-deployed-model
AZURE_AI_CHAT_KEY Azure OpenAI Chat API key Found in Azure Portal → Azure OpenAI resource → Keys and Endpoint e.g. xxxxxx
AOAI_API_KEY Azure OpenAI API key Found in Azure Portal → Azure OpenAI resource → Keys and Endpoint e.g. xxxxxx
GPT4O_DEPLOYMENT_NAME GPT-4 model deployment name Found in Azure Portal → Azure OpenAI resource → Model Deployments
GPT4O_API_KEY GPT-4 API key Found in Azure Portal → Azure OpenAI resource → Keys and Endpoint
SUBSCRIPTION_ID Azure subscription ID Found in Azure Portal → Subscriptions
RESOURCE_GROUP_NAME Resource group name Name of your Azure resource group
PROJECT_NAME AI Foundry project name Name of your AI Foundry project in Azure
USER_CLIENT_ID User-defined managed identity (Optional) Used only for online evaluations. Create in Azure Portal → Managed Identities
CONNECTION_STRING AI Foundry project connection string Found in AI Foundry project settings (Must be enclosed in quotes)
PROMPTY_FILE Path to prompt template file Local path to your prompt template file

Example .env File

AZURE_OPENAI_API_VERSION=2024-02-01
AZURE_AI_CHAT_ENDPOINT=https://your-resource.openai.azure.com/openai/deployments/your-deployed-model
AZURE_AI_CHAT_KEY=your-chat-key
AOAI_API_KEY=your-openai-key
GPT4O_DEPLOYMENT_NAME=your-deployment-name
GPT4O_API_KEY=your-gpt4-key
SUBSCRIPTION_ID=your-subscription-id
RESOURCE_GROUP_NAME=your-resource-group
PROJECT_NAME=your-project-name
USER_CLIENT_ID=your-client-id
CONNECTION_STRING="your-connection-string"
PROMPTY_FILE=xxxxx.prompty

Additional configuration for Semantic Kernel agent with AI Foundry

AZURE_AI_AGENT_PROJECT_CONNECTION_STRING=”your-connection-string” AZURE_AI_AGENT_MODEL_DEPLOYMENT_NAME=your-deployment-name AZURE_AI_AGENT_ENDPOINT=https://xxxdomain.openai.azure.com/ AZURE_AI_AGENT_SUBSCRIPTION_ID==your-subscription-id AZURE_AI_AGENT_RESOURCE_GROUP_NAME=your-resource-group AZURE_AI_AGENT_PROJECT_NAME=your-project-name

AZURE_AI_AGENT_ENDPOINT value is available from Azure AI Foundry Overview page under Endpoints and keys section associated with Azure OpenAI Service key

Important Notes

Verification

To verify your setup:

  1. Ensure your conda environment is activated
  2. Verify Azure login status
  3. Test package installation by running a simple command
  4. Check environment variables are loaded correctly

Troubleshooting