Skip to content

Commit 23ffe40

Browse files
E8-T1: Add Azure AI Foundry configuration to README and QUICKSTART
Co-authored-by: dylan-mccarthy <[email protected]>
1 parent 39bd623 commit 23ffe40

File tree

2 files changed

+221
-1
lines changed

2 files changed

+221
-1
lines changed

README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ docker-compose down
7878
- Control Plane API: http://localhost:8080
7979
- Admin UI: http://localhost:3000
8080

81+
> **Note**: Docker Compose does not include Azure AI Foundry. You must configure Azure AI Foundry credentials in `src/Node.Runtime/appsettings.json` or use environment variables. See [Azure AI Foundry Configuration](#azure-ai-foundry-configuration) section below.
82+
8183
### Option 3: Local Development (No Docker)
8284

8385
Build and run individual services for development:
@@ -118,6 +120,23 @@ The API will be available at `http://localhost:5109`.
118120

119121
#### Running Node Runtime
120122

123+
Before running the Node Runtime, **configure Azure AI Foundry** (required for agent execution):
124+
125+
```bash
126+
# Option 1: Use user secrets (recommended for development)
127+
cd src/Node.Runtime
128+
dotnet user-secrets set "AgentRuntime:AzureAIFoundry:Endpoint" "https://your-resource.services.ai.azure.com/models"
129+
dotnet user-secrets set "AgentRuntime:AzureAIFoundry:ApiKey" "your-api-key"
130+
dotnet user-secrets set "AgentRuntime:AzureAIFoundry:DeploymentName" "gpt-4o-mini"
131+
132+
# Option 2: Use environment variables
133+
export AgentRuntime__AzureAIFoundry__Endpoint="https://your-resource.services.ai.azure.com/models"
134+
export AgentRuntime__AzureAIFoundry__ApiKey="your-api-key"
135+
export AgentRuntime__AzureAIFoundry__DeploymentName="gpt-4o-mini"
136+
```
137+
138+
Then start the Node Runtime:
139+
121140
```bash
122141
cd src/Node.Runtime
123142
dotnet run
@@ -134,6 +153,134 @@ The Node Runtime will:
134153
- PostgreSQL 14 or later (for production use)
135154
- Redis 6.0 or later (for lease and lock management)
136155
- NATS Server 2.10+ with JetStream enabled (for event streaming)
156+
- **Azure AI Foundry** or **Azure OpenAI Service** (for LLM-powered agent execution)
157+
158+
## Azure AI Foundry Configuration
159+
160+
The platform uses **Azure AI Foundry** (or Azure OpenAI Service) to power LLM-based agent execution. You must configure Azure AI Foundry for agents to process requests using AI models like GPT-4.
161+
162+
### Quick Setup
163+
164+
1. **Create Azure AI Foundry Resource**:
165+
```bash
166+
# Create resource group
167+
az group create --name rg-bpa-agents --location eastus
168+
169+
# Create Azure AI Foundry resource
170+
az cognitiveservices account create \
171+
--name my-ai-foundry \
172+
--resource-group rg-bpa-agents \
173+
--kind AIServices \
174+
--sku S0 \
175+
--location eastus
176+
```
177+
178+
2. **Deploy a Model**:
179+
- Navigate to your Azure AI Foundry resource in the Azure Portal
180+
- Go to "Deployments" → "Create new deployment"
181+
- Select model: `gpt-4o-mini` (recommended for cost-effective MVP)
182+
- Name: `gpt-4o-mini`
183+
- Note your endpoint: `https://your-resource.services.ai.azure.com/models`
184+
185+
3. **Configure Node Runtime** (edit `src/Node.Runtime/appsettings.json`):
186+
```json
187+
{
188+
"AgentRuntime": {
189+
"DefaultModel": "gpt-4o-mini",
190+
"DefaultTemperature": 0.7,
191+
"MaxTokens": 4000,
192+
"MaxDurationSeconds": 60,
193+
"AzureAIFoundry": {
194+
"Endpoint": "https://your-resource.services.ai.azure.com/models",
195+
"DeploymentName": "gpt-4o-mini",
196+
"ApiKey": "your-api-key-here",
197+
"UseManagedIdentity": false
198+
}
199+
}
200+
}
201+
```
202+
203+
> **Security Best Practice**: Never commit API keys to source control. Use one of these approaches:
204+
> - **Development**: `dotnet user-secrets set "AgentRuntime:AzureAIFoundry:ApiKey" "your-key"`
205+
> - **Production**: Use Managed Identity (set `UseManagedIdentity: true`) or Azure Key Vault
206+
> - **Environment Variables**: `export AgentRuntime__AzureAIFoundry__ApiKey="your-key"`
207+
208+
### Supported Models
209+
210+
Azure AI Foundry supports various models for different use cases:
211+
212+
| Model Family | Model | Best For | Cost |
213+
|-------------|-------|----------|------|
214+
| **GPT-4 Optimized** | `gpt-4o` | Latest performance, multimodal | $$$ |
215+
| | `gpt-4o-mini` | Cost-effective, fast, recommended for MVP | $ |
216+
| **GPT-4** | `gpt-4` | Complex reasoning tasks | $$$$ |
217+
| | `gpt-4-32k` | Extended context (32K tokens) | $$$$$ |
218+
| **GPT-3.5** | `gpt-3.5-turbo` | Fast, cost-effective | $ |
219+
| | `gpt-3.5-turbo-16k` | Extended context (16K tokens) | $$ |
220+
221+
### Configuration Options
222+
223+
| Setting | Required | Default | Description |
224+
|---------|----------|---------|-------------|
225+
| `Endpoint` || - | Azure AI Foundry endpoint URL |
226+
| `DeploymentName` || - | Model deployment name in Azure |
227+
| `ApiKey` |* | - | API key for authentication |
228+
| `UseManagedIdentity` | | `false` | Use Azure Managed Identity instead of API key |
229+
230+
\* Required if `UseManagedIdentity` is `false`
231+
232+
### Using Managed Identity (Recommended for Production)
233+
234+
Managed Identity eliminates the need for API keys:
235+
236+
```json
237+
{
238+
"AgentRuntime": {
239+
"AzureAIFoundry": {
240+
"Endpoint": "https://your-resource.services.ai.azure.com/models",
241+
"DeploymentName": "gpt-4o-mini",
242+
"UseManagedIdentity": true
243+
}
244+
}
245+
}
246+
```
247+
248+
Grant your Node Runtime's managed identity access:
249+
250+
```bash
251+
# Get Node Runtime's managed identity principal ID
252+
PRINCIPAL_ID=$(az aks show --name my-aks --resource-group my-rg --query identityProfile.kubeletidentity.clientId -o tsv)
253+
254+
# Get Azure AI Foundry resource ID
255+
AI_RESOURCE_ID=$(az cognitiveservices account show --name my-ai-foundry --resource-group rg-bpa-agents --query id -o tsv)
256+
257+
# Assign Cognitive Services User role
258+
az role assignment create \
259+
--assignee $PRINCIPAL_ID \
260+
--role "Cognitive Services User" \
261+
--scope $AI_RESOURCE_ID
262+
```
263+
264+
### Budget & Cost Management
265+
266+
Control costs by setting budget constraints in agent definitions:
267+
268+
```json
269+
{
270+
"agentId": "invoice-classifier",
271+
"budget": {
272+
"maxTokens": 2000,
273+
"maxDurationSeconds": 30
274+
}
275+
}
276+
```
277+
278+
The platform automatically tracks token usage and costs for each run. Monitor in:
279+
- Azure Portal: Cost analysis for Azure AI Foundry
280+
- Application logs: Token usage per execution
281+
- OpenTelemetry metrics: `run_tokens`, `run_cost_usd`
282+
283+
**For detailed Azure AI Foundry configuration, see [docs/AZURE_AI_FOUNDRY_INTEGRATION.md](docs/AZURE_AI_FOUNDRY_INTEGRATION.md).**
137284

138285
## Database Setup
139286

infra/QUICKSTART.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,48 @@ This script will create:
4040
- ✅ Azure Database for PostgreSQL
4141
- ✅ Azure Cache for Redis
4242
- ✅ Azure Key Vault
43-
- ✅ Azure OpenAI Service
43+
-**Azure OpenAI Service (Azure AI Foundry)** - LLM endpoint for agent execution
4444
- ✅ Azure Container Registry
4545
- ✅ Application Insights
4646

4747
**Expected time:** 15-20 minutes
4848

49+
> **Note**: The deployment automatically creates an Azure OpenAI Service (Azure AI Foundry) resource. After deployment, you need to deploy a model (e.g., `gpt-4o-mini`) through the Azure Portal.
50+
51+
### 2a. Deploy Azure AI Foundry Model (Required)
52+
53+
After infrastructure deployment completes, deploy an AI model:
54+
55+
```bash
56+
# Get Azure OpenAI resource name
57+
OPENAI_NAME=$(az deployment group show \
58+
--name bpa-dev-deployment \
59+
--resource-group $RESOURCE_GROUP \
60+
--query properties.outputs.openAiName.value \
61+
--output tsv)
62+
63+
# Deploy gpt-4o-mini model (recommended for MVP)
64+
az cognitiveservices account deployment create \
65+
--name $OPENAI_NAME \
66+
--resource-group $RESOURCE_GROUP \
67+
--deployment-name gpt-4o-mini \
68+
--model-name gpt-4o-mini \
69+
--model-version "2024-07-18" \
70+
--model-format OpenAI \
71+
--sku-capacity 10 \
72+
--sku-name Standard
73+
74+
echo "✅ Model deployed: gpt-4o-mini"
75+
echo "Endpoint: $(az cognitiveservices account show --name $OPENAI_NAME --resource-group $RESOURCE_GROUP --query properties.endpoint -o tsv)"
76+
```
77+
78+
**Alternative models you can deploy:**
79+
- `gpt-4o` - Latest GPT-4 optimized (higher cost, better performance)
80+
- `gpt-4` - Standard GPT-4 (highest cost, best reasoning)
81+
- `gpt-3.5-turbo` - Fastest, most cost-effective
82+
83+
> **Tip**: For MVP testing, `gpt-4o-mini` offers the best balance of cost and performance.
84+
4985
## 3. Build and Push Images
5086

5187
```bash
@@ -168,6 +204,43 @@ curl http://localhost:8080/health
168204

169205
## Troubleshooting
170206

207+
### Azure AI Foundry Issues
208+
209+
#### Model not deployed?
210+
```bash
211+
# List all deployments
212+
OPENAI_NAME=$(az deployment group show \
213+
--name bpa-dev-deployment \
214+
--resource-group $RESOURCE_GROUP \
215+
--query properties.outputs.openAiName.value \
216+
--output tsv)
217+
218+
az cognitiveservices account deployment list \
219+
--name $OPENAI_NAME \
220+
--resource-group $RESOURCE_GROUP
221+
```
222+
223+
#### Node Runtime can't connect to Azure AI Foundry?
224+
```bash
225+
# Check logs for Node Runtime pods
226+
kubectl logs -l app.kubernetes.io/component=node-runtime --tail=100
227+
228+
# Common issues:
229+
# 1. Model not deployed - see "Model not deployed?" above
230+
# 2. Invalid API key - verify Key Vault secret: openai-api-key
231+
# 3. Endpoint mismatch - verify Key Vault secret: openai-endpoint
232+
# 4. Deployment name mismatch - should be "gpt-4o-mini" (or your chosen model)
233+
```
234+
235+
#### Verify Azure AI Foundry configuration in cluster
236+
```bash
237+
# Check if secrets are correctly configured
238+
kubectl get secret azure-secrets -o jsonpath='{.data.openai-endpoint}' | base64 -d
239+
kubectl get secret azure-secrets -o jsonpath='{.data.openai-api-key}' | base64 -d
240+
241+
# Expected endpoint format: https://<resource-name>.openai.azure.com/
242+
```
243+
171244
### Pod not starting?
172245
```bash
173246
kubectl describe pod <pod-name>

0 commit comments

Comments
 (0)