Azure Deployment Guide

Learn how to deploy AgenticFleet on Microsoft Azure using various services.

Deployment Options

  1. Azure App Service
  2. Azure Kubernetes Service (AKS)
  3. Azure Container Instances
  4. Azure Functions
  5. Azure Virtual Machines

Azure App Service

Configuration

# azure-app-service.yaml
language: python
python:
  version: 3.11
startup_file: startup.sh
env_variables:
  AGENTIC_FLEET_API_KEY: ${API_KEY}
  DATABASE_URL: ${DATABASE_URL}

Deployment Script

#!/bin/bash
# startup.sh
gunicorn app:app --bind=0.0.0.0:8000 --workers=4 --timeout=120

GitHub Actions Workflow

name: Deploy to Azure App Service

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.11'
    
    - name: Deploy to Azure
      uses: azure/webapps-deploy@v2
      with:
        app-name: 'agentic-fleet'
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

Azure Kubernetes Service (AKS)

AKS Cluster Creation

# Create resource group
az group create --name agentic-fleet-rg --location eastus

# Create AKS cluster
az aks create \
  --resource-group agentic-fleet-rg \
  --name agentic-fleet-aks \
  --node-count 3 \
  --enable-addons monitoring \
  --generate-ssh-keys

Azure Container Registry

# Create ACR
az acr create \
  --resource-group agentic-fleet-rg \
  --name agenticfleetacr \
  --sku Standard

# Build and push container
az acr build \
  --registry agenticfleetacr \
  --image agentic-fleet:latest .

AKS Deployment

# aks-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: agentic-fleet
spec:
  replicas: 3
  selector:
    matchLabels:
      app: agentic-fleet
  template:
    metadata:
      labels:
        app: agentic-fleet
    spec:
      containers:
      - name: agentic-fleet
        image: agenticfleetacr.azurecr.io/agentic-fleet:latest
        ports:
        - containerPort: 8000
        env:
        - name: AGENTIC_FLEET_API_KEY
          valueFrom:
            secretKeyRef:
              name: fleet-secrets
              key: api-key
        resources:
          requests:
            cpu: "250m"
            memory: "512Mi"
          limits:
            cpu: "500m"
            memory: "1Gi"

Azure Application Gateway

# app-gateway.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: agentic-fleet-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - host: api.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: agentic-fleet
            port:
              number: 80

Azure Container Instances

Container Group

# Create container group
az container create \
  --resource-group agentic-fleet-rg \
  --name agentic-fleet \
  --image agenticfleetacr.azurecr.io/agentic-fleet:latest \
  --dns-name-label agentic-fleet \
  --ports 80 \
  --environment-variables \
    AGENTIC_FLEET_API_KEY=$API_KEY \
    DATABASE_URL=$DATABASE_URL

Container Compose

# azure-container-compose.yaml
version: '3.8'
services:
  api:
    image: agenticfleetacr.azurecr.io/agentic-fleet:latest
    environment:
      - AGENTIC_FLEET_API_KEY=${API_KEY}
      - DATABASE_URL=${DATABASE_URL}
    ports:
      - "80:8000"

Azure Functions

Function App

# function_app.py
import azure.functions as func
from agentic_fleet.integrations.azure import AzureFunctionHandler

app = func.FunctionApp()
handler = AzureFunctionHandler()

@app.route(route="chat")
async def chat(req: func.HttpRequest) -> func.HttpResponse:
    return await handler.handle_request(req)

Function Configuration

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.*, 4.0.0)"
  }
}

Azure Virtual Machines

ARM Template

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vmName": {
      "type": "string",
      "defaultValue": "agentic-fleet-vm"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2021-03-01",
      "name": "[parameters('vmName')]",
      "location": "[resourceGroup().location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_D2s_v3"
        },
        "osProfile": {
          "computerName": "[parameters('vmName')]",
          "adminUsername": "azureuser"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "Canonical",
            "offer": "UbuntuServer",
            "sku": "18.04-LTS",
            "version": "latest"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', 'nic')]"
            }
          ]
        }
      }
    }
  ]
}

Azure Database Integration

Azure PostgreSQL

from agentic_fleet.integrations.azure import AzurePostgresStorage

storage = AzurePostgresStorage(
    host="your-server.postgres.database.azure.com",
    database="fleet",
    user="azure@your-server",
    password="your-password"
)

Azure Cosmos DB

from agentic_fleet.integrations.azure import CosmosDBStorage

storage = CosmosDBStorage(
    url="https://your-account.documents.azure.com",
    key="your-key",
    database="fleet",
    container="agents"
)

Azure Cache for Redis

from agentic_fleet.integrations.azure import AzureRedisCache

cache = AzureRedisCache(
    host="your-cache.redis.cache.windows.net",
    port=6380,
    password="your-key",
    ssl=True
)

Azure Monitor Integration

Application Insights

from agentic_fleet.integrations.azure import AppInsights

insights = AppInsights(
    connection_string="your-connection-string"
)

# Track custom event
insights.track_event(
    name="fleet_created",
    properties={
        "fleet_id": "fleet_123",
        "agent_count": 3
    }
)

# Track dependency
insights.track_dependency(
    name="OpenAI API",
    duration=1.5,
    success=True
)

Azure Log Analytics

from agentic_fleet.integrations.azure import LogAnalytics

logs = LogAnalytics(
    workspace_id="your-workspace-id",
    shared_key="your-shared-key"
)

# Send logs
logs.send_log(
    category="FleetOperations",
    message="Fleet initialized",
    properties={
        "fleet_id": "fleet_123",
        "status": "active"
    }
)

Azure Security Best Practices

  1. Key Vault Integration
from agentic_fleet.integrations.azure import KeyVault

vault = KeyVault(
    vault_url="https://your-vault.vault.azure.net/"
)

# Get secret
api_key = await vault.get_secret("agentic-fleet-api-key")
  1. Managed Identity
from agentic_fleet.integrations.azure import ManagedIdentity

identity = ManagedIdentity()
token = await identity.get_token("https://database.azure.com")
  1. Network Security
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: fleet-network-policy
spec:
  podSelector:
    matchLabels:
      app: agentic-fleet
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          role: frontend
    ports:
    - protocol: TCP
      port: 8000

Deployment Checklist

  1. Infrastructure

    • Resource group created
    • Network configured
    • Database provisioned
    • Cache configured
    • Storage accounts set up
  2. Security

    • Key Vault configured
    • Managed identities enabled
    • Network policies applied
    • SSL/TLS enabled
    • RBAC configured
  3. Monitoring

    • Application Insights enabled
    • Log Analytics configured
    • Alerts set up
    • Metrics collection enabled
    • Dashboard created
  4. Scaling

    • Auto-scaling rules defined
    • Load balancer configured
    • Resource quotas set
    • Performance testing completed
    • Capacity planning done