Putting an AI model behind an API key and calling it from your app is the easy part. Securing it properly takes a handful of habits. These are the controls we teach in the defence half of our AI Security course.
Use Identity Instead of Keys
Prefer Microsoft Entra ID and managed identities over API keys. A managed identity removes secrets from your code, and access can be revoked centrally. Where you must use keys, rotate them and store them in Key Vault.
Lock Down the Network
Use private endpoints and firewall rules, and disable public network access if your workload allows it. This keeps your AI endpoint off the open internet.
Apply Least-Privilege RBAC
Give each person and service only the roles they need, for example separating who can call a model from who can change its deployment or content filters.
Keep Secrets Out of Code
Store secrets in Azure Key Vault and read them at runtime, or use environment variables for configuration. Never commit keys to source control.
Protect Data with Encryption and Isolation
Consider customer-managed keys, virtual network integration and Bring Your Own Storage when data sensitivity requires more control. Understand what data the service processes and stores.
Add Content Safety Layers
Azure AI Content Safety provides category filters, Prompt Shields for jailbreak and injection detection, and groundedness detection. Treat them as one layer next to hardened system prompts and application controls.
Monitor and Alert
Enable diagnostic logging and metrics, and alert on throttling, content-filter triggers and unusual usage. Review abuse monitoring settings and make sure you know how they apply to your data.
Test Your Own Defences
After you harden a deployment, attack it again with prompt-injection and garak-style tests to see what still gets through. That loop, attack then defend then attack again, is the core of our course capstone.
