Skip to content

Configure Edmund for Azure AI Foundry deployment #1

Configure Edmund for Azure AI Foundry deployment

Configure Edmund for Azure AI Foundry deployment #1

Workflow file for this run

name: Deploy Edmund Agent to Azure AI Foundry
on:
push:
branches: [ main ]
paths:
- 'agents/edmund/**'
pull_request:
branches: [ main ]
paths:
- 'agents/edmund/**'
workflow_dispatch:
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP: copilot-edmund
AZURE_LOCATION: eastus
AGENT_NAME: edmund-engineer
AI_FOUNDRY_PROJECT: edmund-tminus15-project
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install jsonschema pyyaml
- name: Validate agent configuration
run: |
python -c "
import json
import yaml
# Validate agent-config.json
with open('agents/edmund/agent-config.json', 'r') as f:
config = json.load(f)
print('✓ agent-config.json is valid JSON')
# Validate deployment.yaml
with open('agents/edmund/deployment.yaml', 'r') as f:
deployment = yaml.safe_load_all(f)
for doc in deployment:
if doc:
print('✓ deployment.yaml document is valid YAML')
# Check required fields
required_fields = ['agent', 'model', 'instructions']
for field in required_fields:
if field not in config:
raise ValueError(f'Missing required field: {field}')
print('✓ All configuration files are valid')
"
- name: Test configuration syntax
run: |
cd agents/edmund
python -m json.tool agent-config.json > /dev/null
echo "✓ agent-config.json syntax is valid"
deploy-dev:
runs-on: ubuntu-latest
needs: validate
if: github.ref == 'refs/heads/main'
environment: development
steps:
- uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Set up Azure CLI extensions
run: |
az extension add --name ml --version 2.22.0 --yes
az extension add --name ai-examples --yes
az version
- name: Verify Azure subscription and resource group
run: |
echo "Checking Azure subscription..."
az account show --output table
echo "Checking resource group..."
az group show --name $AZURE_RESOURCE_GROUP --output table || {
echo "Creating resource group $AZURE_RESOURCE_GROUP..."
az group create --name $AZURE_RESOURCE_GROUP --location $AZURE_LOCATION
}
- name: Create or update AI Foundry project
run: |
echo "Setting up AI Foundry project..."
# Check if project exists
if ! az ml workspace show --name $AI_FOUNDRY_PROJECT --resource-group $AZURE_RESOURCE_GROUP >/dev/null 2>&1; then
echo "Creating new AI Foundry project..."
az ml workspace create \
--name $AI_FOUNDRY_PROJECT \
--resource-group $AZURE_RESOURCE_GROUP \
--location $AZURE_LOCATION \
--display-name "Edmund T-Minus-15 Agent Project" \
--description "AI Foundry project for Edmund, the Engineering Agent from T-Minus-15 methodology"
else
echo "AI Foundry project already exists"
fi
- name: Configure workspace connection
run: |
echo "Configuring AI Foundry workspace connection..."
az configure --defaults group=$AZURE_RESOURCE_GROUP workspace=$AI_FOUNDRY_PROJECT
- name: Deploy agent configuration
run: |
cd agents/edmund
echo "Preparing agent deployment..."
# Create a deployment package
mkdir -p deployment-package
cp agent-config.json deployment-package/
cp deployment.yaml deployment-package/
cp knowledge-sources.json deployment-package/ 2>/dev/null || echo "knowledge-sources.json not found, skipping"
echo "Agent configuration prepared for deployment"
# Deploy using Azure ML/AI Foundry APIs
echo "Deploying agent to AI Foundry..."
# Create or update the agent deployment
az ml online-deployment create \
--file ai-foundry-deployment.yaml \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--set name=$AGENT_NAME-$(date +%Y%m%d-%H%M%S) \
--set endpoint_name=$AGENT_NAME-endpoint || {
echo "Direct deployment failed, trying alternative approach..."
# Alternative: Create endpoint first, then deployment
az ml online-endpoint create \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--auth-mode key || echo "Endpoint may already exist"
# Then create deployment
az ml online-deployment create \
--file ai-foundry-deployment.yaml \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--set name=$AGENT_NAME-$(date +%Y%m%d-%H%M%S)
}
- name: Test deployment
run: |
echo "Testing agent deployment..."
# Wait for deployment to be ready
sleep 30
# Test agent endpoint
az ml online-endpoint invoke \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--request-file - <<EOF || echo "Deployment test completed (may need additional configuration)"
{
"messages": [
{
"role": "user",
"content": "Hello Edmund, can you help me with a quick engineering question?"
}
]
}
EOF
- name: Update traffic allocation
run: |
echo "Setting traffic allocation to latest deployment..."
# Get the latest deployment name
LATEST_DEPLOYMENT=$(az ml online-deployment list \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--query "[0].name" -o tsv)
if [ ! -z "$LATEST_DEPLOYMENT" ]; then
az ml online-endpoint update \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--traffic "$LATEST_DEPLOYMENT=100"
echo "Traffic allocated to deployment: $LATEST_DEPLOYMENT"
fi
- name: Output deployment information
run: |
echo "=== Deployment Summary ==="
echo "Agent Name: $AGENT_NAME"
echo "Resource Group: $AZURE_RESOURCE_GROUP"
echo "AI Foundry Project: $AI_FOUNDRY_PROJECT"
echo "Location: $AZURE_LOCATION"
# Get endpoint details
az ml online-endpoint show \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--output table || echo "Could not retrieve endpoint details"
echo "=== Deployment Complete ==="
cleanup-old-deployments:
runs-on: ubuntu-latest
needs: deploy-dev
if: github.ref == 'refs/heads/main'
steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Clean up old deployments
run: |
echo "Cleaning up old deployments (keeping latest 3)..."
# Get all deployments for the endpoint
DEPLOYMENTS=$(az ml online-deployment list \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--query "[].name" -o tsv | sort -r)
# Keep only the latest 3, delete the rest
echo "$DEPLOYMENTS" | tail -n +4 | while read deployment; do
if [ ! -z "$deployment" ]; then
echo "Deleting old deployment: $deployment"
az ml online-deployment delete \
--name $deployment \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--yes --no-wait || echo "Could not delete deployment: $deployment"
fi
done