Practice Exams:

Microsoft AI-103: Building Foundry Projects with Python

AI & Machine Learning

A Foundry project can look ready in the portal while a Python application still fails at the first authenticated request. Teams often confuse a project endpoint with a model deployment name, assume that portal access grants data-plane permissions, or copy examples written for an older client version. A dependable setup makes those boundaries explicit before any prompts or agents are developed. This walkthrough treats the Foundry project as an operational environment with identity, endpoint configuration, model deployment, repeatable code and diagnostics. The aim is a small application whose successful and failed requests can both be explained, recreated and audited rather than a notebook that works only for its author.

On this page
  1. Establish what the project is responsible for
  2. Choose the current project endpoint and SDK deliberately
  3. Authenticate without embedding long-lived credentials
  4. Create a minimal request that proves the whole path
  5. Add configuration and model changes under version control
  6. Connect services without widening the trust boundary
  7. Measure reliability before declaring the project production-ready

Establish what the project is responsible for

A Foundry resource and project can coordinate model deployments and agent configuration without owning every dependent service. A Python client may authenticate to the project successfully but still be unauthorized to read a separate Azure AI Search index or Storage container. Record the project endpoint and deployment identity separately, along with which subscription bears each cost, which principal executes each call and which user data the tool may access. Exercise a permitted and denied request before granting broader roles. A working inference call proves one part of the application path, not the security of its retrieval, database and operational dependencies. A Microsoft AI-103 Foundry Python project should prove identity, configuration, and request handling before being treated as a production foundation.

Separate development, evaluation and production configurations when release control or confidential datasets warrant it. Even if all environments share a codebase, they should not automatically share application access credentials, private documents, logs or deployment quotas. Decide where model versions, tool configuration and evaluation results are tracked. A code repository can record approved configuration references without storing tenant secrets or privileged endpoint keys. An operational project starts with ownership and boundaries, not only a green status icon.

Choose the current project endpoint and SDK deliberately

The current Microsoft Foundry SDK works with a service host such as <resource>.services.ai.azure.com and a project path such as /api/projects/<project>; the complete project endpoint combines them under HTTPS. Older examples may instead target Azure OpenAI-specific resources, an agents endpoint or a differently versioned client library. Copying code from several generations can lead to incompatible imports and request models. Record the chosen SDK major version, Python runtime and API surface in the application manifest. Upgrade SDKs through tested releases rather than allowing every environment to resolve an unconstrained latest version.

The Python azure-ai-projects package provides access to Foundry project operations, while azure-identity supplies Azure identity credentials. Microsoft’s current quickstarts show AIProjectClient with DefaultAzureCredential and obtaining a compatible OpenAI client for model calls. The exact package requirement and method signatures should be pinned to the Microsoft Learn quickstart verified on the day of deployment. The project endpoint and the model deployment name are different configuration values: having the first does not create or authorize the second.

Authenticate without embedding long-lived credentials

For an engineer’s development machine, DefaultAzureCredential can use a supported locally authenticated developer identity, but production workloads should use an appropriately scoped managed identity or another approved workload identity. Do not copy a key from the portal into Python source just because a quickstart shows one as a fallback. Where an application must read documents from Azure AI Search or Storage, the Foundry permission alone is insufficient; assign the required role on that dependent resource as well. Entra management permissions and inference or search data-plane permissions are not interchangeable.

Test permissions with the application’s actual runtime identity. A successful portal query under a developer’s account does not prove that a deployed container can call the same service. Log the identity type, resource identifier and permission-denied class while avoiding access tokens or complete authorization headers. A role assignment can take time to propagate, but propagation delay should not become an excuse for granting broad permanent access. Keep diagnostic steps that distinguish wrong tenant, wrong audience, missing role and unreachable private endpoint.

Create a minimal request that proves the whole path

First run a narrow Python smoke test that initializes a Foundry project client, discovers or references an approved deployment and sends one harmless prompt through the documented model API. Use a deliberately unambiguous question with a short expected response and record request correlation, model deployment, latency and token usage when returned. The smoke test is not a quality benchmark: it establishes that the environment, authentication, endpoint and deployment cooperate. A succeeding initialization without a real model response is not an end-to-end test.

A maintainable Python sample should prove the identity and resource boundary before adding a framework. Write a short application that loads the selected project endpoint and model deployment from configuration, requests a token through a supported credential chain and submits one narrowly specified inference. Record the authenticated principal and the resource scope it needs in a separate deployment note, not in an error message or source-code comment containing secrets. Test the command locally with the intended developer identity and again using the managed identity planned for deployment. If one succeeds and the other receives a permission failure, do not resolve the difference by granting unrestricted project ownership.

Turn the example into an integration test by checking response schema, request correlation ID, timeout handling and the absence of confidential values in logs. Simulate a deployment-name typo, quota rejection and unavailable service endpoint. A retry should be bounded and reserved for failures that can reasonably recover; invalid credentials and malformed configuration require correction rather than repeated requests. Only after these tests pass should the sample incorporate document retrieval, tracing or agents. The result demonstrates the SDK and service contract without claiming that one successful notebook call proves production readiness.

Handle failures as typed operational outcomes. An authentication failure suggests credentials or audience; a 403 requires role or resource checks; an unrecognized deployment points to a model configuration mistake; quota throttling requires capacity or retry policy changes. A transient 429 can be retried with bounded exponential backoff and jitter, but repeating a non-idempotent tool action without status reconciliation is dangerous. Put network timeouts and maximum retries in explicit configuration so users do not wait indefinitely for a service that is unavailable.

Add configuration and model changes under version control

Create an environment-specific configuration record containing the Foundry project endpoint, intended model deployment, optional search endpoint, evaluation dataset revision and application version. Never put API tokens into that record. A versioned release manifest should describe which deployment names the application expects and who approved changes. Model aliases and deployment routing can change independently of the Python commit, so the deployed state must be recorded alongside the code. Consider how cached clients, connection pools and agent state respond when a model is switched during a release.

Define an upgrade test with representative prompts, safety cases and expected latency and cost ranges. A deployment can remain callable after an upgrade but change response formatting, tool selection or image capabilities. Use a reversible rollout for meaningful changes, record exactly which client and model version produced a regression, and give responders a tested way to restore the last approved configuration. Clean up unused deployments, but do not delete an old version before validating its replacement and the references that still depend on it.

Connect services without widening the trust boundary

A real Azure AI application often reads from Azure AI Search, invokes a tool and stores results in a separate business system. Give each dependency a narrowly scoped identity and distinguish read-only retrieval from write-capable actions. Source access controls must remain effective after text has been chunked or copied into a search index. A prompt that mentions a confidential document is not permission for the application to disclose it. When a tool can trigger a side effect, validate its arguments and authorization outside the language model.

Test the full chain with two identities: one allowed to access a specific dataset and one expressly denied. Both cases should be visible in safe diagnostic logs, and the forbidden case must not leak matching snippets through search results, error messages or model context. Assess private networking, DNS and egress requirements alongside identity. A correct SDK call still fails if its endpoint is not reachable from the application runtime. Avoid treating network reachability and permission checks as interchangeable evidence.

Measure reliability before declaring the project production-ready

Capture successful and unsuccessful requests across the client, Foundry service, model deployment and dependent resources. Monitor request rate, throttling, latency percentile, retries, response validity and estimated cost. A log entry saying that an HTTP call returned 200 does not establish that an answer was grounded or that a downstream business operation completed. Add task-level validation and representative evaluation cases to the smoke test. Preserve enough version information to tell a model-quality change from a data-ingestion problem.

A production readiness review should verify owner and rollback contact, least-privilege identities, deployed configuration, private data handling, retention limits, known regional or preview constraints and a reproducible environment setup. Run a recovery drill in which a deployment is temporarily unavailable: the application should fail clearly, apply bounded retries or route to a documented alternative, and avoid duplicating external actions. A trustworthy Foundry Python project is not defined by how quickly its first example runs. It is defined by how predictably the same approved code behaves when identities, data, versions and capacity change.

Continue learning

Related guides

Azure AI Foundry Model SelectionSelect models by real task quality, latency, cost, and deployment limits.Python SDK Patterns for Azure AIStructure Python SDK clients, error handling, and resilient Azure AI calls.Securing Azure AI EndpointsCombine endpoint authentication, network policy, and access controls.Managed Identity for AI Application CredentialsUse managed identity and narrowly scoped Azure service authorization.

Related Posts

• Think Smart, Build Smarter: Mastering AI-900 with Microsoft Azure

• Microsoft AI-103: Building Reliable RAG Retrieval

• Microsoft AB-900: Conditional Access in an AI-Enabled Workplace

• Microsoft AI-103: Choosing Azure AI Deployment Types

• Microsoft AI-103: Diagnosing Hallucinations in Azure AI

• Microsoft AI-103: Protecting RAG from Poisoned Data

• Microsoft AI-103: Threat Modeling Azure AI Systems

• Microsoft AB-100: Building an AI Champions Program

• Microsoft AB-100: GitHub Copilot Code Review Workflows

• Microsoft AB-100: Monitoring Copilot Studio Agents