A Python web app must call agents and models in a Foundry project without storing keys. Which setup is correct?
- Exam domain
- Implement generative AI and agentic solutions30–35% of the exam
- Difficulty
- Medium
- In this mock
- 20 questions on this domainPractise this domain
Why the exam asks this
Implement generative AI and agentic solutions: Build generative applications by using Foundry.
Objective in the exam guide: Configure an application to connect to a Foundry project.
Every Foundry app starts with this connection. The exam checks the pieces: endpoint, credential and client.
Why B is the answer
Create an AIProjectClient with the project endpoint and DefaultAzureCredential
The Foundry SDK's project client takes the project endpoint and an Entra ID credential, then gives access to the project's agents, models and connections.
Remember: Connect with the project endpoint and an Entra credential.
How it works
A Foundry project has an endpoint URL. The SDK's AIProjectClient connects to it.
Passing DefaultAzureCredential means no key: it picks up a managed identity, environment credentials or a developer sign-in.
From the client you reach agents, model deployments, connections and telemetry settings.
Clues in the question
The words that point to the answer, and what each one tells you.
- Without storing keys
- An Entra ID credential.
- Foundry project
- The project endpoint.
In detail
- DefaultAzureCredential uses a managed identity in Azure and your developer sign-in locally.
- The identity needs a suitable role on the Foundry resource.
Side by side with look-alikes
| Piece | Value |
|---|---|
| Client | AIProjectClient |
| Endpoint | The project endpoint URL |
| Credential | DefaultAzureCredential |
| Role | Granted to the identity on the resource |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Connect to the project through the Azure portal from the server at run timeWrong
The portal is for people, not for an app at run time.
B. Create an AIProjectClient with the project endpoint and DefaultAzureCredentialRight
Connect with the project endpoint and an Entra credential.
C. Paste an API key into the source code and call each model's URLWrongMost tempting
Keys in source code are the worst place for a secret.
Why it tempts: It works quickly, so it is a common shortcut. But it puts a secret in source control and bypasses the project.
D. Copy the agent's instructions into the app and call no serviceWrong
Copying instructions loses the agent's tools and model.
In practice
- Keep the project endpoint in configuration, not code.
Use case
An illustrative scenario, not a real incident.
A web app uses AIProjectClient with DefaultAzureCredential; in Azure it runs under a managed identity, and on a laptop under the developer's sign-in.
See how it works
flowchart LR W["Web app"] --> C["AIProjectClient(endpoint, DefaultAzureCredential)"] C --> E["Entra ID token"] C --> P["Foundry project"] P --> A["Agents"] P --> M["Model deployments"] P --> K["Connections"]
How to read this chart
- "Web app" leads to "AIProjectClient(endpoint, DefaultAzureCredential)".
- "AIProjectClient(endpoint, DefaultAzureCredential)" leads to "Entra ID token" and "Foundry project".
- "Foundry project" leads to "Agents" and "Model deployments" and "Connections".