Create and manage external models (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Implement AI capabilities in database solutions (25–30%)
   --> Design and implement models and embeddings
      --> Create and manage external models


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

One of the major additions to Microsoft SQL Server 2025, Azure SQL Database, and Azure SQL Managed Instance is the ability to directly integrate with external Artificial Intelligence (AI) models. Rather than exporting data to a separate application, developers can invoke Large Language Models (LLMs), embedding models, or other AI services directly from SQL code. This significantly simplifies the development of intelligent database applications.

For the DP-800 exam, candidates should understand how external models are configured, managed, secured, monitored, and consumed from SQL databases. They should also understand the architectural considerations involved in connecting SQL Server to external AI services such as Azure OpenAI Service, Azure AI Foundry models, GitHub Models, or other OpenAI-compatible endpoints.


What Are External Models?

An external model is an AI model that is hosted outside the SQL database but can be invoked securely from SQL statements.

Instead of training or hosting the model inside SQL Server, SQL sends requests to the model through a configured endpoint.

Examples include:

  • Azure OpenAI GPT models
  • Azure AI Foundry models
  • OpenAI API models
  • GitHub Models
  • Cohere models
  • Meta Llama models
  • Mistral AI models
  • Other OpenAI-compatible endpoints

The SQL database becomes an intelligent application layer capable of performing AI operations while leaving model hosting and scaling to specialized AI services.


Why Use External Models?

External AI models provide capabilities such as:

  • Natural language generation
  • Text summarization
  • Classification
  • Translation
  • Sentiment analysis
  • Content generation
  • Question answering
  • Embedding generation
  • Semantic search
  • Retrieval-Augmented Generation (RAG)

Without external models, these tasks would require exporting database data into an application layer before AI processing.


Benefits of External Models

Using external models provides several advantages:

Reduced Application Complexity

Applications can invoke AI directly from SQL instead of implementing additional middleware.

Centralized Data Processing

Data remains closer to where it is stored, reducing unnecessary movement.

Simplified Development

Developers write SQL instead of building custom AI integration layers.

Enterprise Security

Authentication occurs through secure credentials and managed identities.

Scalability

The external AI provider handles model hosting, GPU infrastructure, scaling, and updates.


External Model Architecture

A typical architecture consists of:

Application
Azure SQL Database
External Model Definition
Credential
HTTPS Endpoint
Azure OpenAI / AI Foundry / OpenAI

SQL sends HTTPS requests to the configured endpoint and returns the model’s response to the calling application.


Components of an External Model

An external model configuration typically includes:

  • Model name
  • Endpoint URL
  • Authentication method
  • API version
  • Deployment name
  • Credentials
  • Optional timeout settings
  • Model capabilities

Supported AI Services

DP-800 focuses primarily on Microsoft’s AI ecosystem.

Common supported services include:

Azure OpenAI Service

Most common deployment option.

Supports:

  • GPT-4
  • GPT-4.1
  • GPT-4o
  • GPT-4 Turbo
  • Embedding models

Azure AI Foundry

Provides access to multiple foundation models from various providers.

Examples include:

  • Meta Llama
  • Mistral
  • Cohere
  • Phi models
  • DeepSeek (where available)

OpenAI-Compatible APIs

SQL can communicate with services implementing the OpenAI API specification.


Creating an External Model

The general process includes:

Step 1

Deploy a model in Azure AI Foundry or Azure OpenAI.


Step 2

Create authentication credentials.

Examples include:

  • API Keys
  • Microsoft Entra ID authentication
  • Managed Identity

Step 3

Create an external model definition inside SQL.

This associates:

  • endpoint
  • deployment
  • credentials
  • model metadata

Step 4

Test connectivity.

Execute SQL queries that invoke the model.


Step 5

Monitor usage.

Review:

  • failures
  • latency
  • token consumption
  • throttling

Authentication Methods

Security is a major exam topic.

Supported authentication methods include:

API Keys

Simple to configure.

Advantages:

  • Easy setup

Disadvantages:

  • Requires secure storage
  • Must be rotated regularly

Microsoft Entra ID

Recommended for enterprise deployments.

Benefits:

  • Central identity management
  • Conditional Access
  • Role-Based Access Control
  • No hardcoded secrets

Managed Identity

Preferred when SQL services interact with Azure services.

Advantages:

  • No passwords
  • Automatic credential rotation
  • Strong security posture

Managing Credentials

Credentials should never be hardcoded into SQL scripts.

Best practices include:

  • Azure Key Vault
  • Managed Identity
  • Secure credential objects
  • Secret rotation
  • Least privilege

Model Configuration Considerations

When selecting a model, evaluate:

  • Latency
  • Cost
  • Context window
  • Maximum tokens
  • Supported languages
  • Multimodal support
  • Structured outputs
  • Function calling
  • Embedding support
  • Regional availability

Model Version Management

AI models evolve frequently.

Developers should:

  • Test new versions
  • Validate prompt compatibility
  • Measure output quality
  • Compare latency
  • Evaluate token costs
  • Deploy gradually

Avoid automatically replacing production models without validation.


Monitoring External Models

Important operational metrics include:

  • Request count
  • Failed requests
  • Average latency
  • Token usage
  • Cost
  • Timeout frequency
  • Authentication failures
  • Rate limiting
  • Model availability

Monitoring may be performed using Azure Monitor, Azure OpenAI metrics, Application Insights, and Log Analytics.


Error Handling

Applications should anticipate failures such as:

  • Network interruptions
  • Authentication failures
  • Invalid prompts
  • Model timeouts
  • Rate limiting
  • Endpoint unavailability
  • Quota exhaustion

Applications should implement:

  • Retry logic
  • Exponential backoff
  • Logging
  • Graceful degradation
  • User-friendly error messages

Cost Management

External AI services typically charge based on token usage.

Cost optimization strategies include:

  • Select smaller models when appropriate.
  • Minimize unnecessary prompts.
  • Cache reusable responses.
  • Use embeddings instead of repeated generation where applicable.
  • Monitor token consumption.
  • Apply rate limits where appropriate.

Security Best Practices

Microsoft recommends:

  • Use Microsoft Entra ID whenever possible.
  • Store secrets securely.
  • Rotate API keys regularly.
  • Restrict network access.
  • Enable auditing.
  • Monitor authentication failures.
  • Apply least privilege.
  • Encrypt data in transit.
  • Avoid sending sensitive information unnecessarily.

Best Practices for DP-800

Candidates should remember the following:

  • External models are hosted outside SQL.
  • SQL communicates with models over secure HTTPS endpoints.
  • Azure OpenAI and Azure AI Foundry are primary Microsoft AI services.
  • Managed Identity is generally preferred over API keys in Azure.
  • Never hardcode secrets.
  • Monitor token usage and latency.
  • Plan for retries and transient failures.
  • Validate model updates before production deployment.
  • Balance performance, cost, and model capabilities.
  • Use the smallest model that satisfies business requirements.

DP-800 Exam Tips

For the exam, be prepared to:

  • Differentiate between external models and local database objects.
  • Understand authentication methods.
  • Identify secure credential storage mechanisms.
  • Select appropriate model types.
  • Monitor AI usage and performance.
  • Recommend enterprise security practices.
  • Manage model lifecycle and versioning.
  • Understand cost optimization strategies.
  • Configure reliable AI integrations.
  • Recognize scenarios where Azure OpenAI or Azure AI Foundry is the preferred solution.

Key Takeaways

Creating and managing external models enables SQL databases to leverage modern AI capabilities without hosting AI infrastructure locally. By securely connecting SQL Server or Azure SQL to services like Azure OpenAI or Azure AI Foundry, developers can incorporate intelligent features such as summarization, classification, semantic search, and RAG directly into database applications. Success depends on proper authentication, secure credential management, monitoring, version control, cost optimization, and selecting the right model for each workload.


Practice Exam Questions

Question 1

A developer wants to enable an Azure SQL Database application to generate natural language summaries using GPT-4o hosted in Azure OpenAI. What is the primary purpose of creating an external model?

A. To copy the AI model into SQL Server memory

B. To allow SQL to securely invoke an externally hosted AI model

C. To convert SQL queries into Python scripts

D. To replace stored procedures with AI-generated code

Correct Answer: B

Explanation: External models define the connection between SQL and an externally hosted AI service. The model remains hosted in Azure OpenAI or another provider, while SQL securely sends requests to it.


Question 2

Which authentication method is generally recommended for Azure SQL Database accessing Azure OpenAI in an enterprise environment?

A. Username and password authentication

B. Shared administrator account

C. Managed Identity

D. Anonymous authentication

Correct Answer: C

Explanation: Managed Identity eliminates the need to store secrets, supports automatic credential rotation, and integrates with Microsoft Entra ID, making it Microsoft’s recommended authentication approach for Azure resources.


Question 3

An organization wants to minimize operational overhead while securely accessing external AI models. Which authentication mechanism best satisfies this requirement?

A. API keys stored in application code

B. SQL logins

C. Managed Identity

D. Local Windows accounts

Correct Answer: C

Explanation: Managed Identity removes the need to manually manage secrets and provides secure, automatic authentication between Azure services.


Question 4

Which factor should be monitored most closely to help control the operational cost of external language models?

A. Token consumption

B. Number of database indexes

C. Memory allocated to SQL Server

D. CPU utilization on the SQL Server

Correct Answer: A

Explanation: Most external LLM providers charge based on token usage. Monitoring prompt and completion tokens helps organizations estimate and manage AI costs.


Question 5

A developer needs to securely store API credentials used by an external model.

Which solution follows Microsoft security best practices?

A. Store the API key in Azure Key Vault

B. Save the API key in a table within the application database

C. Embed the API key in application source code

D. Place the API key in a configuration file committed to source control

Correct Answer: A

Explanation: Azure Key Vault provides secure storage, access policies, auditing, and secret rotation capabilities, making it the recommended location for sensitive credentials.


Question 6

Why should organizations validate new versions of external AI models before deploying them into production?

A. New versions always increase latency.

B. New versions cannot process SQL data.

C. Model behavior, output quality, and performance characteristics may change.

D. SQL Server requires a database restart after every model update.

Correct Answer: C

Explanation: AI model updates can alter response quality, reasoning, formatting, latency, and cost. Testing ensures compatibility with existing applications and prompts.


Question 7

Which capability is provided by Azure AI Foundry that benefits SQL developers?

A. It hosts only Microsoft-developed language models.

B. It provides access to multiple foundation models from different providers.

C. It automatically creates SQL indexes.

D. It replaces Azure SQL Database.

Correct Answer: B

Explanation: Azure AI Foundry offers access to numerous foundation models from Microsoft and third-party providers, enabling developers to select the most appropriate model for their workloads.


Question 8

An external model begins returning timeout errors during peak business hours.

Which application design strategy should be implemented?

A. Disable authentication.

B. Delete and recreate the database.

C. Increase the number of SQL indexes.

D. Implement retry logic with exponential backoff.

Correct Answer: D

Explanation: Transient failures, including timeouts, are common in distributed systems. Retry logic with exponential backoff improves resilience without overwhelming the external service.


Question 9

Which statement best describes an external AI model?

A. It is stored entirely within the SQL database.

B. It executes as a SQL stored procedure.

C. It is hosted externally and accessed through a secure endpoint.

D. It permanently replaces relational queries.

Correct Answer: C

Explanation: External AI models remain hosted outside the database. SQL communicates with them using secure HTTPS requests through configured endpoints.


Question 10

When selecting between multiple external AI models, which combination of evaluation criteria is most appropriate?

A. Number of SQL tables and indexes

B. Latency, cost, capabilities, context window, security, and accuracy

C. File system capacity only

D. Number of database users

Correct Answer: B

Explanation: Choosing the right external model requires balancing functional capabilities with operational considerations such as latency, cost, accuracy, security, supported features, and context window size.


Go to the DP-800 Exam Prep Hub main page

Leave a comment