Skip to content
Visual explainer 3h to learn 5 steps

Choose Azure AI services for an application

Compare Azure Machine Learning, Microsoft Foundry and Azure AI Search and design an approved deployment with identity, data flow and costs.

By Invicly Tech, , in Microsoft Azure Cloud Engineering. About 15 minutes to read.

Topic 30 of 33

In short

Azure has three main AI building blocks. Azure Machine Learning trains, tracks and hosts your own models; Microsoft Foundry gives your app access to ready-made models and agents behind one resource; Azure AI Search indexes your documents so a model can answer from your own data. A sound design picks the fewest of these that meet the need and wires them together with managed identities, not API keys.

Think of it like this: Azure Machine Learning is a workshop where you build your own engine, Foundry is a dealer where you lease a ready engine, and AI Search is the map you hand the driver.

Explained simply

Most apps that use AI do not train a model. They send text to a model that already exists and get text back. On Azure you do that through Microsoft Foundry. You create a Foundry resource, deploy a model into it, and your app calls that deployment over HTTPS. Foundry used to be called Azure AI Foundry, and before that Azure AI Studio.

A model only knows what it learned in training. It does not know your refund policy. To fix that, you search your own documents first and paste the best passages into the prompt. This is called retrieval-augmented generation, or RAG. Azure AI Search is the service that stores and searches those documents.

Azure Machine Learning is for a different job. You use it when you must train or fine-tune your own model, track experiments, and host that model yourself. It is more work and more compute, so choose it only when a ready model plus search does not solve the problem.

Security matters more here because prompts can contain private data. Give your app a managed identity, an Azure identity with no password, and grant it only the roles it needs. Then switch off API keys. Decide which data is sent to the model, what is stored, and what is logged.

Models are billed mostly by tokens, small chunks of text. Search is billed by tier and size. Both can surprise you. Work out a rough monthly cost before you build, and set a budget alert. To learn for free, replace the model with a fake function that returns a fixed answer and focus on the design.

Press Play on a diagram to walk through it one step at a time.

SequenceA grounded answer with managed identity
User
API (managed identity)
Azure AI Search
Foundry model deployment
  1. 1Asks: what is our refund window?
    User to API (managed identity): Asks: what is our refund window?
  2. 2Hybrid query with Entra token
    API (managed identity) to Azure AI Search: Hybrid query with Entra token
  3. 3Top 3 policy passages
    Azure AI Search to API (managed identity): Top 3 policy passages
  4. 4Prompt with passages, Entra token
    API (managed identity) to Foundry model deployment: Prompt with passages, Entra token
  5. 5Answer citing the passages
    Foundry model deployment to API (managed identity): Answer citing the passages
  6. 6Answer plus source links
    API (managed identity) to User: Answer plus source links
CompareWhich service does which job
Azure Machine Learning
  • Train and fine-tune your own models
  • Track experiments and register models
  • Host models on managed online endpoints
  • You pay for the compute you run
Microsoft Foundry
  • Catalogue of ready models and agents
  • Deploy a model, call it from your app
  • Usually billed per token or reserved throughput
  • Foundry resource with projects
Azure AI Search
  • Indexes documents and vectors
  • Keyword, vector and hybrid queries
  • Supplies grounding passages
  • Billed per service tier and units
LayersAn approved AI deployment, outside in
  1. 1
    Users

    Signed in with Entra ID; group decides which documents they see

  2. 2
    API on Container Apps

    Managed identity, rate limits, logs token counts not prompts

  3. 3
    Private endpoints

    Foundry, AI Search and Storage reachable only from the VNet

  4. 4
    Foundry resource

    One project, approved model deployment, content filters, keys off

  5. 5
    Azure AI Search

    Index with security field; role-based data access

  6. 6
    Governance

    Azure Policy allowed models and regions, budget alert, diagnostic logs

In depth

Azure Machine Learning or Microsoft Foundry

Ask one question first: do we need to change a model, or just use one? If you only need to use one, a model deployment in Foundry is enough. Foundry gives you a catalogue of models from Microsoft, OpenAI and other providers, plus agents, evaluations and tracing. The current setup is a Foundry resource containing one or more projects; older hub-based projects now live in the Foundry (classic) portal.

Azure Machine Learning is a workspace for the full training life cycle. It has compute instances for notebooks, compute clusters for training jobs, a registry for models, and managed online endpoints for hosting. You pay for every VM hour those compute targets run. Pick it for custom tabular models such as churn prediction, for fine-tuning with full control, or when data scientists need tracked experiments.

  • Use a model: Foundry deployment
  • Change a model: fine-tuning or Azure Machine Learning
  • Predict from your own tabular data: Azure Machine Learning
  • Both are Azure resources that respect RBAC and private networking

Ground answers with Azure AI Search

AI Search holds an index, a set of documents with fields. An indexer or your own code loads content into it. For RAG you split long documents into chunks of a few hundred words, turn each chunk into a vector, a list of numbers that captures meaning, and store both the text and the vector.

At question time, run a hybrid query: keyword search finds exact terms such as a product code, vector search finds passages with similar meaning, and the results are merged. An optional semantic ranker reorders the top results. Send the best three to five chunks to the model with an instruction to answer only from them and cite them. Keep a security field on each chunk, such as the allowed group, and filter on it so users never get passages they could not open themselves.

FlowPreparing documents for grounding
  1. 1
    Collect

    Policy PDFs in a Blob container

  2. 2
    Chunk

    Split into passages of a few hundred words

  3. 3
    Embed

    Embedding model turns each chunk into a vector

  4. 4
    Index

    Text, vector, source URL and allowed group per chunk

  5. 5
    Refresh

    Re-run when documents change; remove deleted ones

Use identity for model access

Foundry and AI Search both accept Microsoft Entra ID tokens. Your API runs with a managed identity, asks Entra for a token, and sends it with each call. Access then depends on Azure role assignments, which you can review, scope and remove.

For the sample app, the API identity gets Foundry User on the Foundry resource to call model deployments, and Search Index Data Reader on the search service to query. The indexing job gets Search Index Data Contributor instead, because it writes. The search service must have role-based access enabled for data calls. Once roles work, disable key-based access, because a key grants full access with no role checks. Keep humans out of production data paths too: developers can test in a separate project with synthetic documents.

  • API: Foundry User and Search Index Data Reader
  • Indexer: Search Index Data Contributor and Storage Blob Data Reader
  • Foundry User was previously named Azure AI User
  • Disable keys after role-based calls succeed

Trace the data flow

Draw every hop a piece of customer text takes. The question arrives at your API, goes to AI Search as a query, comes back with passages, goes to the model inside a prompt, and returns as an answer. Each hop is a place where data is sent, stored or logged.

For each hop, note the region, whether traffic stays on a private endpoint, and what is kept. Your own logs may capture full prompts, which turns a log workspace into a store of personal data. Log token counts, latency and document IDs instead of full text where you can. Check the data, privacy and abuse-monitoring terms for the model you deploy on Microsoft Learn, and record the answer in your design. Content filters on the deployment block some harmful input and output, but they do not replace your own access checks.

Estimate costs before you build

Model cost is roughly requests times tokens per request times price per token. Input tokens include the system prompt and every retrieved passage, so five long chunks can cost more than the question and answer together. Pay-per-token deployments suit uneven traffic. Provisioned throughput reserves capacity at a fixed price and suits steady, high volume.

AI Search is billed per hour for the tier and the number of replicas and partitions. The Free tier is for small experiments only. Add embedding calls when you index or re-index, storage for the documents, and log ingestion. A worked guess, even within a factor of two, is enough to choose a design. Prices change, so take current numbers from the Azure pricing calculator and label your figures as illustrative.

MapWhere the monthly bill comes from
AI feature cost
  • Model calls
    • Input tokens: prompt and passages
    • Output tokens: the answer
    • Pay-per-token or provisioned
  • AI Search
    • Tier hours
    • Replicas and partitions
    • Semantic ranker usage
  • Indexing
    • Embedding calls
    • Re-index after changes
  • Operations
    • Log ingestion and retention
    • Blob storage for sources

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Compare Azure Machine Learning and Foundry~35m
  2. 2
    Ground answers with Azure AI Search~35m
  3. 3
    Use identity for model access~35m
  4. 4
    Trace the data flow~35m
  5. 5
    Estimate costs~35m

Key points

  • Start with a deployed model in Foundry; reach for Azure Machine Learning only when you must train.
  • Grounding with AI Search lets the model answer from your documents without retraining it.
  • Give the app a managed identity with Foundry User and Search Index Data Reader, then turn off keys.
  • Draw the data flow: what leaves your network, what is stored, and what is logged.
  • Estimate tokens per request times requests per day before you pick a deployment type.

Key terms

Tap a card to flip it. 0/6 known

Examples

Grant the API identity least-privilege AI access

The sample API already runs with a user-assigned managed identity. Prerequisites: a Foundry resource with one model deployment, an AI Search service with role-based access enabled, and Owner or Role Based Access Control Administrator on the resource group. Steps: look up the principal ID, then assign two roles at resource scope. Evidence: az role assignment list shows both, and the API's call returns 200 instead of 401 or 403 after a few minutes. Rollback: delete the two assignments. The Foundry User role is assigned by its ID because the display name was recently renamed from Azure AI User.

bash
RG=rg-contoso-ai
PRINCIPAL=$(az identity show -g $RG -n id-api --query principalId -o tsv)
FOUNDRY=$(az resource show -g $RG -n fdy-contoso --resource-type Microsoft.CognitiveServices/accounts --query id -o tsv)
SEARCH=$(az resource show -g $RG -n srch-contoso --resource-type Microsoft.Search/searchServices --query id -o tsv)

# Foundry User (formerly Azure AI User)
az role assignment create --assignee-object-id $PRINCIPAL --assignee-principal-type ServicePrincipal \
  --role 53ca6127-db72-4b80-b1b0-d745d6d5456d --scope $FOUNDRY
az role assignment create --assignee-object-id $PRINCIPAL --assignee-principal-type ServicePrincipal \
  --role "Search Index Data Reader" --scope $SEARCH

az role assignment list --assignee $PRINCIPAL --all -o table

An illustrative monthly cost estimate

Contoso's help assistant expects 2,000 questions a day. Each prompt carries a 300-token system prompt, a 50-token question and five passages of 250 tokens, so about 1,600 input tokens, plus a 250-token answer. The script multiplies this out with placeholder prices; replace them with current figures from the pricing calculator. The result shows input tokens dominate, so trimming passages from five to three saves more than shortening answers. Local alternative: this is design work and costs nothing.

python
requests_per_month = 2_000 * 30
input_tokens = 300 + 50 + 5 * 250
output_tokens = 250

# Placeholder prices per million tokens: replace with current figures
price_in, price_out = 0.40, 1.60

model = requests_per_month * (input_tokens * price_in + output_tokens * price_out) / 1_000_000
search_tier_month = 75.0  # placeholder for a small paid tier

print(f"input tokens/month: {requests_per_month * input_tokens:,}")
print(f"model: ${model:,.2f}  search: ${search_tier_month:,.2f}")

Quick reference

  • Use a ready model: Foundry deployment. Train or fine-tune with full control: Azure Machine Learning.
  • Answer from your documents: Azure AI Search plus a model, known as RAG.
  • API identity roles: Foundry User on the Foundry resource, Search Index Data Reader on the search service.
  • Indexer roles: Search Index Data Contributor plus Storage Blob Data Reader on the source container.
  • Foundry User role ID: 53ca6127-db72-4b80-b1b0-d745d6d5456d (old name Azure AI User).
  • Disable API keys once Entra ID calls work; a key bypasses role checks.
  • Cost = requests x (input tokens x in-price + output tokens x out-price), plus search tier hours.
  • Log token counts, latency and document IDs, not full prompts.

Common mistakes

  • Shipping an API key in app settings when a managed identity and a role assignment would do.
  • Training a custom model in Azure Machine Learning for a problem that prompting plus search solves.
  • Forgetting that the search index holds copies of your documents, so it needs the same access rules.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A team wants a chatbot that answers from 500 HR policy pages. Which design needs the least new work?

Question 2

2Which role should the indexing job that writes chunks into the index receive?

Question 3

3Why disable key-based access after managed identity works?

Question 4

4In a typical RAG prompt, which part usually costs the most tokens?

Question 5

5When is Azure Machine Learning the better choice than a Foundry deployment?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    For three features, pick Foundry, Azure Machine Learning, AI Search or a combination: summarise support tickets; predict which customers will cancel; answer staff questions from the handbook.

  2. Exercise 2medium

    Write the role assignments for the API, the indexing job and a developer, each at the narrowest scope. State which roles are not needed.

  3. Exercise 3hard

    Build a local, zero-cost RAG prototype: a list of synthetic policy passages, a keyword retriever, and a fake model that returns the top passage with its ID. Then list what changes when you move to Azure.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Is Microsoft Foundry the same as Azure OpenAI?
Azure OpenAI models are available through Foundry, which also offers models from other providers plus agents and evaluation tools. An existing Azure OpenAI resource can be upgraded to a Foundry resource.
Does the model learn from my prompts?
Read the data, privacy and security terms for the specific model and deployment type on Microsoft Learn and record the answer in your design. Do not assume; terms can differ between models and providers.
Do I need vectors, or is keyword search enough?
Keyword search finds exact terms well. Vectors find passages that mean the same thing in different words. Hybrid search runs both and is a sensible default for RAG.
Can I try this without an Azure bill?
You can design and prototype locally with a fake model and a simple retriever. AI Search has a Free tier for small tests, but model calls are paid, so set a budget alert before using real deployments.

Go deeper

ShareXLinkedInWhatsApp