Azure-AI_Foundry

Lesson 3: Networking & Security

Secure your AI Foundry environment with private endpoints, managed VNets, managed identity, and Key Vault integration.

Network Security Options

Azure AI Foundry provides three networking modes:

Mode Internet Access Use Case
Public Full internet access Development, learning, POCs
Private Endpoint No public access; accessed via VNet Production workloads
Managed VNet Azure manages the VNet for you Simplified production security

📖 Docs: Configure Private Link


Private Endpoints

Private endpoints place your AI Foundry hub on a private IP address within your VNet:

resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-11-01' = {
  name: '${hubName}-pe'
  location: location
  properties: {
    subnet: {
      id: subnetId
    }
    privateLinkServiceConnections: [
      {
        name: '${hubName}-connection'
        properties: {
          privateLinkServiceId: hub.id
          groupIds: ['amlworkspace']
        }
      }
    ]
  }
}

Required private endpoints for a fully private deployment:

  1. AI Foundry Hub (amlworkspace)
  2. Storage Account (blob, file)
  3. Key Vault (vault)
  4. Container Registry (registry)
  5. Azure OpenAI (account)
  6. Azure AI Search (searchService)

💡 Tip: In production, always use private endpoints. The initial setup is more complex, but it eliminates the attack surface from public internet exposure.


Managed VNet

Managed VNet simplifies networking — Azure creates and manages the VNet for you:

az ml workspace update \
  --name my-ai-hub \
  --resource-group rg-ai-foundry \
  --managed-network allow-internet-outbound

Three outbound modes:

  1. Allow Internet Outbound — compute can reach internet (simplest)
  2. Allow Only Approved Outbound — whitelist specific destinations
  3. Disabled — no managed VNet (use your own)

📖 Docs: Configure Managed Network


Managed Identity

Always use managed identity for service-to-service authentication:

from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

# No API keys needed — uses managed identity
credential = DefaultAzureCredential()
client = AIProjectClient(
    credential=credential,
    endpoint="https://<hub>.api.azureml.ms",
    project_name="my-project"
)

System-Assigned vs User-Assigned

Type Lifecycle Use Case
System-Assigned Tied to the resource Simple setups, single-resource identity
User-Assigned Independent of resource Multiple resources sharing one identity

💡 Tip: Use system-assigned managed identity for hubs and projects. Use user-assigned only when you need the same identity across multiple resources or when policy requires it.


Key Vault Integration

Hub automatically creates a Key Vault for storing:

Access secrets in your code:

from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential

client = SecretClient(
    vault_url="https://my-keyvault.vault.azure.net/",
    credential=DefaultAzureCredential()
)
secret = client.get_secret("my-api-key")

💡 Tip: Never store secrets in code or environment variables in production. Always use Key Vault with managed identity.


Diagnostic Logging

Enable diagnostic logging to track all API calls and operations:

# Create Log Analytics workspace
az monitor log-analytics workspace create \
  --resource-group rg-ai-foundry \
  --workspace-name ai-foundry-logs

# Enable diagnostics on the hub
az monitor diagnostic-settings create \
  --name hub-diagnostics \
  --resource <hub-resource-id> \
  --workspace <log-analytics-id> \
  --logs '[{"categoryGroup":"allLogs","enabled":true}]'

Security Checklist


🔗 Additional Resources