Plan, Create & Deploy a Microsoft Foundry Service
Now that you know which service to pick (Topic 1), this topic covers how to actually create it in Azure, choose the right model, set up your Python SDK, and deploy your service — in the cloud, in a container, or on an edge device.
This topic uses terms you learned in Topic 1: endpoint, API key, resource, resource group, subscription, region, and SDK. If any of these feel unfamiliar, revisit Topic 1 Section 1 before continuing.
Terms introduced in this topic
These words will appear in exam questions about resource creation and deployment. Learn them here before the concepts below use them.
The act of creating and configuring an Azure resource so it's ready to use. When someone says "provision an Azure AI resource", they mean "create it in the Azure portal or via code and configure its settings".
Azure Resource Manager template. A JSON file that describes the Azure resources you want to create — like a blueprint. You can deploy the same set of resources consistently across environments (dev, test, prod) by running the same template.
A simpler, more readable language for writing ARM templates. Instead of JSON, you use a cleaner syntax. Bicep compiles down to ARM JSON automatically. Think of it as a friendlier way to write the same infrastructure blueprints.
A value stored in your operating system (not in your code) that
your program can read at runtime. Used to store secrets like API keys
so they never appear in your source code. In Python you read them
with os.environ.get("KEY_NAME").
A lightweight, portable package that contains your application code plus everything it needs to run — the right version of Python, all its libraries, etc. Containers run the same way everywhere: on your laptop, in Azure, or on an edge device.
The most common platform for building and running containers. A Docker image is the blueprint for a container. A Docker container is a running instance of that image. Azure provides official Docker images for many AI services.
The simplest way to run a container in Azure. No servers to manage — you just say "run this Docker image" and Azure handles the rest. Best for short-lived tasks, testing, or low-traffic workloads.
A managed Kubernetes cluster for running many containers at scale with automatic scaling, load balancing, and self-healing. Best for production workloads that need high availability and must handle variable traffic.
Running an AI model on a local device (a camera, a factory machine, a hospital scanner) rather than in the cloud. Used when internet connectivity is unreliable, latency must be extremely low, or data must not leave the premises.
Continuous Integration / Continuous Delivery. An automated workflow that tests and deploys your code every time you push a change. Azure DevOps and GitHub Actions are the two platforms the exam expects you to know for integrating AI services into CI/CD.
A model is the AI brain (e.g. GPT-4o, text-embedding-ada-002). A service is the Azure infrastructure that hosts and runs the model (e.g. Azure OpenAI resource). You create a service first, then deploy a model inside it.
In the context of Azure OpenAI and Foundry, a deployment is a named instance of a model hosted inside your resource. You give it a name (e.g. "my-gpt4o") and then reference that name in your code. One resource can have multiple deployments of different models.
What to decide before provisioning any Azure AI resource
Exam questions often describe a scenario where a company has made a wrong planning decision and asks what should have been done differently. These are the decisions you must plan before creating a resource.
You wouldn't start building a house without knowing: what city it's in (region), how big it needs to be (pricing tier), who will have access (RBAC), and whether it needs to be connected to a private road instead of a public street (private endpoint). Azure AI resources are the same — get these decisions wrong and you'll have to delete and recreate the resource.
Choose the Azure region closest to your users for low latency. Also check that the service and model you need is available there — not all services are in all regions. For compliance, choose a region in the same country as your data (e.g. Canada Central for Canadian data).
Exam tip: Azure AI Vision Studio requires East US 2 or West US 2 for the full feature set. This specific region requirement is tested.
From Topic 1 you know: F0 is free but limited. S0 is standard and paid. For production or for anything that needs private endpoints or high call volumes, you need S0. You cannot change tier after creation without recreating the resource.
A multi-service resource (called "Azure AI Services") gives you one endpoint and one key that works for Vision, Language, Speech, and more. A single-service resource (e.g. just "Azure AI Language") is dedicated to one service. Use multi-service for simplicity; use single-service when you need separate billing, quotas, or access control per service.
Before deploying, verify your solution aligns with Microsoft's Responsible AI principles (covered in detail in Topic 5). The planning stage is where you identify risks: could this system be unfair to certain groups? Does it handle personal data safely? These questions must be answered before you build.
Step-by-step: Create an Azure AI Language resource
This walkthrough creates the Azure AI Language service — the one we used in Topic 1's Python example. The steps are almost identical for any Azure AI service.
Go to portal.azure.com and sign in with your Microsoft account. If you don't have an Azure account, create a free one at azure.microsoft.com/free — you get $200 credit for 30 days and many services free for 12 months.
In the top search bar, type Language and select Language service from the results. Then click + Create.
A dialog appears asking if you want to add custom features like Custom Text Classification or Custom NER. For the exam you need to know these exist, but for a basic setup click Continue to create your resource.
Subscription: Your Azure subscription.
Resource Group: Create new or pick existing — this is the folder that holds your resource.
Region: Pick the region closest to your users (or East US 2 for Vision-specific tasks).
Name: A unique name — this becomes part of your endpoint URL.
Pricing Tier: F0 (free) for learning, S0 for production.
Click Review + create. Azure validates your settings. If validation passes, click Create. Deployment takes about 30–60 seconds.
Once deployed, click Go to resource.
In the left menu, click Keys and Endpoint.
You will see KEY 1, KEY 2, and
Endpoint. Copy these — you need them in your Python code.
The endpoint looks like:
https://your-resource-name.cognitiveservices.azure.com/
If you put your API key directly in your Python file and push it to GitHub, anyone can see it and rack up charges on your Azure account. In this topic's code examples we'll show the correct way: reading the key from an environment variable.
How to store your API key safely
Before we write any code that uses your newly created resource, you need to know how to store your key safely. An environment variable is a value stored in your operating system — outside of your code — that your Python program can read. This way your key never appears in your script.
Step 1 — Set the environment variable
Run this in your terminal before running your Python script:
# On Windows Command Prompt:
set LANGUAGE_KEY=your-actual-key-here
set LANGUAGE_ENDPOINT=https://your-resource-name.cognitiveservices.azure.com/
# On Mac/Linux terminal:
export LANGUAGE_KEY=your-actual-key-here
export LANGUAGE_ENDPOINT=https://your-resource-name.cognitiveservices.azure.com/
Step 2 — Read the variable in Python
Python's built-in os module lets you read environment variables.
The os module is part of Python itself — no installation needed.
# "import os" loads Python's built-in operating system module
# This module lets you interact with your operating system, including reading environment variables
import os
# os.environ is a dictionary of all environment variables on your system
# .get("LANGUAGE_KEY") retrieves the value stored under that name
# If the variable doesn't exist, .get() returns None instead of crashing
key = os.environ.get("LANGUAGE_KEY")
# Same for the endpoint URL
endpoint = os.environ.get("LANGUAGE_ENDPOINT")
# Now "key" and "endpoint" hold your values, but they never appear as text in your code
print(key) # This would print your actual key at runtime — but only you can run this
print(endpoint) # And your actual endpoint URL
The exam won't ask you to write environment variable commands.
But it will show you Python code that uses os.environ.get()
and ask what it's doing — now you know. In production you'd use
Azure Key Vault to store secrets (covered in Topic 3).
How to install any Azure AI SDK
Every Azure AI service has its own Python SDK package you install with pip. Here are the packages the exam most commonly references — you need to recognise which package belongs to which service.
| Azure AI Service | pip install command | Main import |
|---|---|---|
| Azure AI Language | pip install azure-ai-textanalytics |
from azure.ai.textanalytics import TextAnalyticsClient |
| Azure AI Vision | pip install azure-ai-vision-imageanalysis |
from azure.ai.vision.imageanalysis import ImageAnalysisClient |
| Azure AI Speech | pip install azure-cognitiveservices-speech |
import azure.cognitiveservices.speech as speechsdk |
| Azure AI Document Intelligence | pip install azure-ai-formrecognizer |
from azure.ai.formrecognizer import DocumentAnalysisClient |
| Azure AI Search | pip install azure-search-documents |
from azure.search.documents import SearchClient |
| Azure OpenAI | pip install openai |
from openai import AzureOpenAI |
| Azure AI Content Safety | pip install azure-ai-contentsafety |
from azure.ai.contentsafety import ContentSafetyClient |
| Azure Identity (for Managed Identity auth) | pip install azure-identity |
from azure.identity import DefaultAzureCredential |
The exam shows code snippets with the import statement removed and asks
which package needs to be installed. The trickiest one:
Document Intelligence's pip package is still called
azure-ai-formrecognizer (the old service name),
even though the service is now called Document Intelligence.
Always install azure-ai-formrecognizer for Document Intelligence work.
Complete setup script — Language service
Below is the complete, production-ready setup. Notice how it uses environment variables for the key and endpoint rather than hard-coding them. A new Python concept appears here: if/else — explained in the comments.
# ── Import modules ─────────────────────────────────────────────────────
# os gives us access to environment variables
import os
# sys lets us exit the program if something goes wrong
import sys
# The Azure Language SDK client
from azure.ai.textanalytics import TextAnalyticsClient
# The credential helper for API key authentication
from azure.core.credentials import AzureKeyCredential
# ── Read credentials from environment variables ────────────────────────
key = os.environ.get("LANGUAGE_KEY")
endpoint = os.environ.get("LANGUAGE_ENDPOINT")
# ── Safety check (new concept: if/else) ───────────────────────────────
# "if" checks a condition. If the condition is True, the indented block runs.
# "not key" means "if key is empty or None (doesn't exist)"
# "or" means EITHER condition can trigger the error
if not key or not endpoint:
# print() displays a message to the user
print("Error: Please set LANGUAGE_KEY and LANGUAGE_ENDPOINT environment variables.")
# sys.exit(1) stops the program with an error code (1 means something went wrong)
sys.exit(1)
# ── Create the client ──────────────────────────────────────────────────
# Wrap the key in a credential object
credential = AzureKeyCredential(key)
# Create the client — our connection to the Language service
client = TextAnalyticsClient(endpoint=endpoint, credential=credential)
print("✅ Client created successfully. Ready to call the Language service.")
Models vs Services — and how to pick a model
For most Azure AI services (Language, Vision, Speech), Microsoft manages the underlying models for you — you just call the service and it uses the best available model automatically.
However for Azure OpenAI, you must explicitly choose and deploy a model. Here are the models you need to know for the exam:
| Model | What it does | Choose when |
|---|---|---|
gpt-4o |
Most capable chat/text model. Understands text AND images (multimodal). | Complex reasoning, document analysis with images, high-quality outputs needed. |
gpt-4 |
Highly capable text model. Text only. | Complex text tasks where multimodal not needed. Lower cost than GPT-4o. |
gpt-35-turbo |
Fast, cost-effective chat model. | High-volume, budget-conscious chat applications. Simpler tasks. |
text-embedding-ada-002 |
Converts text into a list of numbers (a vector/embedding). | Semantic search, RAG (Retrieval-Augmented Generation), similarity comparisons. |
dall-e-3 |
Generates images from text descriptions. | Any scenario requiring AI-generated images. |
whisper |
Transcribes audio to text (speech-to-text via OpenAI). | High-accuracy audio transcription via OpenAI's model. |
Any exam question about vector search, RAG patterns, or semantic
similarity will involve an embedding model.
The embedding model used in Azure OpenAI is
text-embedding-ada-002. Know this name cold.
You'll see it again in Part 2 (Generative AI) and Part 5 (Knowledge Mining).
Three ways to deploy an Azure AI service
The exam presents scenarios asking which deployment option best fits the requirements. There are three options and each has a clear use case.
The service runs entirely in Microsoft's data centres. You call it over the internet using your endpoint URL. Microsoft manages all the infrastructure, scaling, and updates. This is the default and most common deployment.
Microsoft provides Docker container images for many AI services (Language, Speech, Vision). You run these containers on your own servers or in Azure Container Instances / AKS. The AI processing happens locally but billing still reports back to Azure.
A container running on a local edge device — a factory machine, a camera, an IoT device. Uses Azure IoT Edge or similar. The AI model runs directly on the device with no cloud round-trip per inference.
Container deployment — what the exam tests
The exam frequently asks about running Azure AI service containers. There is a specific Docker run command pattern you must recognise. Below is the Language service sentiment container as an example.
# This is a Docker command (not Python) — you run it in your terminal
# "docker run" starts a new container from an image
# --rm means: delete the container automatically when it stops (no cleanup needed)
# -it means: interactive terminal (you can see output as it runs)
# -p 5000:5000 maps port 5000 on your machine to port 5000 in the container
# This lets you call the service at http://localhost:5000
docker run --rm -it -p 5000:5000 \
mcr.microsoft.com/azure-cognitive-services/textanalytics/sentiment \
# ↑ The Docker image location — from Microsoft Container Registry (mcr.microsoft.com)
Eula=accept \
# ↑ REQUIRED: You must accept the licence agreement. Container won't start without this.
Billing=https://your-resource.cognitiveservices.azure.com/ \
# ↑ Your endpoint — used for billing reporting back to Azure (even offline containers bill)
ApiKey=your-api-key
# ↑ Your API key — proves this container is authorised to bill your subscription
Even when running a container completely offline on-premises,
it still needs to connect to Azure periodically to report billing.
The Billing and ApiKey parameters are
required — the container will not start without them.
This is one of the most tested container facts on the exam.
The exam asks how to prevent the API key from being stored in terminal
command history (where anyone could read it later). The answer is to
use environment variables in the Docker command instead
of passing the key directly:
ApiKey=$LANGUAGE_KEY instead of
ApiKey=the-actual-key
This way the key never appears as plain text in your command history.
ACI vs AKS vs Azure App Service — when to use which
| Service | Best for | Scaling | Complexity |
|---|---|---|---|
| ACI Azure Container Instances |
Quick tests, short-lived tasks, dev/test environments | Manual — start/stop instances yourself | Very simple — no cluster to manage |
| AKS Azure Kubernetes Service |
Production workloads, microservices, high traffic | Automatic — scales pods based on load | Complex — Kubernetes knowledge needed |
| Azure App Service | Web apps and APIs hosting — not just containers | Automatic scale-out on App Service Plans | Medium — managed platform |
Default endpoints and naming conventions
The exam shows you endpoint URLs and asks which service they belong to, or asks you to identify the correct endpoint for a given service. Learn the patterns.
| Service | Default Endpoint Pattern | Notes |
|---|---|---|
| Azure AI Services (most) | https://<name>.cognitiveservices.azure.com/ |
The most common pattern. Covers Language, Vision, Speech, Document Intelligence. |
| Azure AI Search | https://<name>.search.windows.net |
Different domain — search.windows.net not cognitiveservices. |
| Azure OpenAI | https://<name>.openai.azure.com/ |
Different domain — openai.azure.com. |
| Old regional endpoints (legacy) | https://eastus2.api.cognitive.microsoft.com/ |
Older pattern still appears in some exam questions. Region is in the URL. |
For the Speech service specifically, when using private endpoints or containers, you must configure a custom subdomain for your resource. The default endpoint format won't work. This is a specific exam trap — if a scenario mentions Speech + private endpoint, the answer involves enabling a custom domain name.
Integrating Foundry Services into a CI/CD pipeline
CI/CD stands for Continuous Integration / Continuous Delivery. It's the practice of automatically testing and deploying your code every time you make a change. The exam wants you to know that this is possible with Azure AI services and which tools are used — not the deep implementation details.
Imagine a car factory. Every time a new car design is approved, the assembly line automatically builds a prototype, tests it, and if tests pass, sends it to showrooms. CI/CD is the same for code — every time you push a change, the pipeline automatically tests your AI application and deploys it to production if everything passes.
Two CI/CD tools you need to know
Microsoft's end-to-end DevOps platform. Includes Pipelines (CI/CD), Repos (code storage), Boards (project management), and Artifacts (package storage). The exam expects you to know that Azure DevOps Pipelines can deploy Azure AI resources using ARM templates or Bicep.
GitHub's built-in automation system. You define workflows in YAML files that run automatically when code is pushed. Microsoft provides official GitHub Actions for deploying to Azure, including actions for Azure AI Foundry deployments.
You will not be asked to write YAML pipeline code. You will be asked:
• Which tool enables automated deployment of Azure AI resources? → Azure DevOps or GitHub Actions
• How are credentials stored securely in a pipeline? → As secret variables / GitHub Secrets (never in YAML directly)
• What format describes infrastructure as code in Azure? → ARM templates (JSON) or Bicep
High availability with multiple regions
A single Azure region can experience outages. For mission-critical applications, you deploy your Azure AI service to multiple regions and use traffic routing to send users to the nearest healthy instance.
Two or more regions are all live simultaneously. Traffic is split between them. If one region fails, all traffic automatically goes to the other. Highest availability but doubles cost.
A DNS-based load balancer. Routes user requests to the closest or healthiest endpoint. Use this to distribute traffic across your multi-region AI service deployments automatically.
Each regional deployment of your AI resource has its own endpoint and keys. Your application must be configured to fall back to the secondary region's endpoint if the primary fails.
What this topic is tested on
1. Document Intelligence SDK package name — Install
azure-ai-formrecognizer even though the service is now
called Document Intelligence. The old package name persists.
2. Containers still need Billing + ApiKey params —
Even offline containers report usage to Azure. Both parameters are
mandatory for the container to start.
3. ACI for testing, AKS for production — If a scenario
mentions "scale automatically" or "high availability" → AKS.
If it says "quick test" or "short-lived" → ACI.
4. Embedding model = text-embedding-ada-002 —
This specific model name appears frequently across Parts 2 and 5.
5. Speech service needs custom domain for private endpoints —
Unique to Speech — other services don't have this requirement.
Test your understanding
5 questions. Select an answer to see the explanation immediately.
A developer is writing Python code to use Azure AI Document Intelligence. Which pip command should they run to install the correct SDK?
B is correct. Even though the service was renamed from Form Recognizer to Document Intelligence, the pip package name remains azure-ai-formrecognizer. This is a classic exam trap — the service name changed but the package name did not. Always install azure-ai-formrecognizer for Document Intelligence work.