MSBA-279 · Lesson 8 of 12 · 19 min

AI features in code-first solutions

▶ Video coming soon A video version of this lesson is on the way.

Wiremu's self-rating for the Foundry agent group was a 1, and Signe's was not much better. So for this topic they did not review; they built. Over two evenings in the week of November 9, 2026, in a practice Azure resource group that Rupert set up with a spending limit and a developer environment holding only invented data, they made a small agent in Microsoft Foundry that could answer questions about practice work orders by reaching Dataverse through its MCP server. "I understand it better after one evening of building than after a week of reading," Wiremu said at the Friday session. "Mostly because of what went wrong."

AI runs through the AB-400 outline rather than sitting in one place. This lesson gathers the AI-related skills from all four domains, then reviews the newest group in the outline, Build Microsoft Foundry agents by using code that integrates with the Microsoft Power Platform, in detail. It builds on the prompts and AI functions taught in Extending the Platform: Plug-ins, Custom APIs and Connectors (MSBA-272) and on the agent design material in Power Platform Technical Design for Developers (MSBA-270).

Where AI appears in the outline

DomainAI-related skillWhat it tests
Build solutionsDetermine when to use deterministic or non-deterministic methodsChoosing rules or AI for a piece of logic
Build solutionsDetermine when to use Microsoft Foundry or Copilot Studio to build agentsChoosing the agent platform
Build solutionsDetermine the UI approach, including interactive agents and MCP app widgetsWhen conversation or agent-rendered UI is the right interface
Build solutionsDesign custom connectors and MCP servers; design custom agentsExposing tools and data to agents
Extend the user experienceConfigure code apps to use agents built in Copilot StudioCalling an agent from a code app
Extend the platformConfigure Copilot Studio workflowsAutomation logic shared with cloud flows
Extend the platformBuild Microsoft Foundry agents that integrate with Power Platform (4 skills)MCP servers, connected agents, Work IQ, the Copilot Studio client library

Together these are perhaps a tenth of the outline, and they are concentrated in decisions and integration rather than in model training or prompt engineering. AB-400 does not ask you to tune a model. It asks whether AI should be used for a piece of logic, which platform should host an agent, and how an agent and Power Platform reach each other securely.

Deterministic and non-deterministic logic, again

The design rule from lesson 4 deserves repetition because it is the gate for every other AI question. Use deterministic logic, such as a plug-in, formula or business rule, when the result must be exact, repeatable or auditable. Use non-deterministic logic, such as a prompt, an AI function or an agent, when the input is unstructured and judgement helps. In a mixed design, the AI produces a suggestion and deterministic code decides what to do with it.

TaskBetter methodReason
Calculate a transcript fee from a rate tableDeterministic: custom APIMoney must be exact and explainable
Classify free-text delivery instructionsNon-deterministic: a prompt, with a confidence thresholdUnstructured text; output is a suggestion
Decide whether a safety work order can closeDeterministic: plug-inSafety rule; must never vary
Summarize a long case history for an adviserNon-deterministic: AI summaryJudgement on text; a person reads the result
Route a request to a queue by categoryMixed: prompt suggests, rule assigns, low confidence goes to reviewSpeed with control

Code calls AI in Dataverse through documented messages and functions. A plug-in or external client can run a prompt built in Power Platform with the Predict message, passing the prompt's inputs and reading its text or structured output; Lumenvale's transcript instructions prompt was called this way from an asynchronous step. Power Fx in apps and in Dataverse functions can call AI functions such as AISummarize, AIClassify, AIExtract, AISentiment, AIReply and AITranslate. Both consume Copilot Credits, and both should be called where a short delay is acceptable, not inside a synchronous step that a user is waiting on.

Copilot Studio or Microsoft Foundry

The choice of agent platform is now its own skill. Copilot Studio is Microsoft's low-code agent platform, governed as part of Power Platform. Agents use topics, knowledge, connectors, flows, Copilot Studio workflows and MCP tools; they publish to Teams, Microsoft 365 Copilot, websites and apps; and environment, data policy and solution ALM apply to them. Microsoft Foundry is Azure's platform for building agents in code. Developers choose models, write orchestration, attach tools including MCP servers, run evaluations and host the agent in Azure under Azure governance.

ConsiderationPoints to Copilot StudioPoints to Microsoft Foundry
Who builds and maintains itMakers and functional consultantsProfessional developers
Main integrationPower Platform connectors, Dataverse, flowsCustom code, Azure services, any API
Model and orchestration controlManaged by the platformDeveloper chooses models and writes orchestration
GovernancePower Platform environments, data policies, solutionsAzure subscriptions, role-based access, Azure policies
PublishingTeams, Microsoft 365 Copilot, websites, code appsCustom applications, APIs, and channels the developer builds

Most real designs use both, which is why three of the four Foundry skills are about connecting the two worlds. A typical question gives a scenario in which developers need a custom orchestration over several internal systems, but business users must reach the result from Teams through an existing Copilot Studio agent. The answer builds the specialist agent in Foundry and connects it to the Copilot Studio agent, rather than forcing everything into one platform.

The Foundry agent skills

A map of connections between a custom agent in Microsoft Foundry and Power Platform. The Foundry agent calls Power Platform MCP servers, including the Dataverse MCP server, as tools. It connects to Copilot Studio agents in both directions. It reaches Microsoft 365 and business application context through Work IQ with delegated sign-in. Applications consume Copilot Studio agents through the Copilot Studio client library.
The four ways a code-built agent integrates with Power Platform in the AB-400 outline.

Integrating through Power Platform MCP servers

The Model Context Protocol lets an agent discover and call tools exposed by a server. Power Platform provides MCP servers, most importantly the Dataverse MCP server, which exposes tools to list and describe tables, query and read rows, and create or update rows, all under the calling user's Dataverse security. A Foundry agent adds the server as an MCP tool, and the model decides when to call it.

Access is governed in the environment. The Dataverse MCP server is enabled for Copilot Studio by default, while other MCP clients must be allowed by an administrator in the environment's settings before they can connect. That was the first thing that went wrong in Signe and Wiremu's build: the Foundry agent could not connect until Rupert allowed the client in the practice environment. The exam version of that experience is a question in which an agent receives an authorization error from the Dataverse MCP server although the user has the right security role; the answer is the environment setting for allowed MCP clients.

Connecting custom agents to Copilot Studio agents

A custom agent can work with Copilot Studio agents in both directions. A Copilot Studio agent can add another agent, including one built in Foundry, as a connected agent that it hands specialist work to. A custom agent or application can call a published Copilot Studio agent to reuse its knowledge, topics and actions. The design question is which agent owns the conversation with the user and which is the specialist. Usually the agent that users already reach in Teams or Microsoft 365 Copilot owns the conversation.

Work IQ

Work IQ is Microsoft's intelligence layer that grounds agents in an organization's work context: mail, meetings, files, chats and business systems. Foundry agents can use it as an MCP tool at a Work IQ MCP endpoint, which Microsoft's documentation describes as generally available, or through a built-in preview tool. Work IQ uses delegated authentication only: requests run in the signed-in user's context and respect that user's permissions, and application-only authentication is not supported. Setting it up requires a one-time tenant step by an administrator to provision the service and grant consent, and usage is billed with Copilot Credits.

Dataverse data reaches Work IQ through Business Applications in Work IQ, which Microsoft documents as a preview and as the successor to the separate Dataverse intelligence service. It depends on settings at several levels: a Microsoft 365 admin center setting to make business applications data available to Copilot for all or selected users, environment settings to enable Copilot and Dataverse search indexing and to allow the data in Microsoft Copilot, and app-level settings in model-driven apps. A question that asks why an agent grounded through Work IQ finds no Dataverse rows for a user is usually answered by one of those settings, or by the fact that the user cannot see the rows.

The Copilot Studio client library

The Copilot Studio client library, part of the Microsoft 365 Agents SDK, lets code consume a Copilot Studio agent: start a conversation, send messages and receive the agent's replies. It is available for .NET, JavaScript and Python, with samples for each. The app signs the user in with Microsoft Entra ID and calls the agent with that user's identity, so the agent's connectors and knowledge respect the user's permissions. Microsoft's documentation notes that the client library works with agents on the standard harness, and that agents on the newer Microsoft Copilot harness are not yet officially supported.

SkillKey facts
Power Platform MCP serversDataverse MCP server exposes table and row tools under the user's security; non-Copilot Studio clients must be allowed in environment settings
Connect to Copilot Studio agentsConnected agents in both directions; the agent users already reach owns the conversation
Work IQMCP endpoint generally available; built-in tool in preview; delegated only; tenant setup and Copilot Credits; Dataverse through Business Applications in Work IQ (preview)
Copilot Studio client library.NET, JavaScript and Python; user sign-in with Entra ID; standard harness agents supported

MCP app widgets and interactive agents

The UI skill in domain 1 lists interactive agents and MCP app widgets alongside code apps and PCF components. An interactive agent is the conversation itself as the interface: users ask and the agent answers or acts. An MCP app widget is richer. An MCP server returns not just data but a small interactive interface, such as a form or a card with buttons, that a host like Microsoft 365 Copilot can display inside the chat. The design question is when conversation is enough and when a user needs structured input or a visual inside it. Choose a widget when users must review or edit structured data in the flow of a chat; choose a code app when the whole experience is a structured application.

Designing custom agents responsibly

The design skills expect the usual safeguards. Give each agent the least access it needs: delegated access when it acts for a user, a narrow application identity when it acts on its own. Require approval before an agent writes data or sends anything outside the organization, as the Work IQ documentation's samples do with an approval requirement on tool calls. Log tool calls to Application Insights so behaviour can be reviewed. Evaluate the agent against a test set before release and after changes, as Lumenvale did with its prompts, where a classification prompt was measured against 50 anonymized cases before use. These are not separate skills in the outline, but they decide between otherwise similar options.

Worked problem

An agent design question

A college wants advisers to ask, in Microsoft Teams, which of their students have holds and upcoming deadlines. Data is in Dataverse and in advisers' calendars. Developers have built a custom orchestration in Microsoft Foundry that ranks urgency. Advisers already use a Copilot Studio agent for policy questions. Answers must show only students each adviser is allowed to see. What design fits?

Show solution
  1. Users already reach a Copilot Studio agent in Teams: keep it as the agent that owns the conversation.
  2. The ranking logic lives in Foundry: connect the Foundry agent as a connected agent for this task.
  3. Dataverse access through the Dataverse MCP server, allowed for the Foundry client in the environment, under the adviser's identity.
  4. Calendar context through Work IQ with delegated sign-in, which respects each adviser's permissions.

Answer: Copilot Studio agent in Teams as the front door; Foundry agent connected for ranking; Dataverse MCP server and Work IQ, both delegated, for data. No application-only access, so each adviser sees only permitted students.

At Lumenvale this example stayed an example. When Dr. Philippa Ondaatje-Ruiz, the privacy officer, heard about the practice build, she asked that nothing like it touch real student data without a privacy review, and Signe agreed. The practice environment held only invented records and was deleted after the session.

Common mistakes

  • MistakeUsing a prompt to calculate a fee or enforce a safety rule.

    InsteadUse deterministic logic for exact results; let AI suggest, and code decide.

  • MistakeAssuming any MCP client can connect to the Dataverse MCP server by default.

    InsteadCopilot Studio is enabled by default; other clients must be allowed in environment settings.

  • MistakeConfiguring Work IQ with application-only authentication for a background agent.

    InsteadWork IQ supports delegated authentication only.

  • MistakeBuilding one giant agent on a single platform.

    InsteadKeep the user-facing agent where users are and connect specialist agents.

Summary and key terms

  • AI skills are spread across the outline and focus on decisions and integration, not model training.
  • Use deterministic logic for exact results; call prompts with Predict and AI functions where a delay is acceptable.
  • Copilot Studio suits maker-owned agents in Power Platform; Foundry suits developer-built agents with custom orchestration.
  • Foundry agents integrate through Power Platform MCP servers, connected Copilot Studio agents, Work IQ and the Copilot Studio client library.
  • MCP app widgets show interactive UI inside a chat; interactive agents make the conversation the interface.
Model Context Protocol (MCP)
An open protocol through which agents discover and call tools exposed by servers.
Dataverse MCP server
A Power Platform MCP server exposing Dataverse table and row tools to agents under user security.
Microsoft Foundry
Azure's platform for building, evaluating and hosting agents in code.
Work IQ
Microsoft's layer that grounds agents in work context such as mail, meetings, files and business data.
Copilot Studio client library
Part of the Microsoft 365 Agents SDK for consuming Copilot Studio agents from code.
Connected agent
An agent that another agent hands specialist tasks to.
MCP app widget
An interactive interface returned by an MCP server and displayed inside a chat.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Which authentication does Work IQ support?

    Show answer

    Delegated authentication in the signed-in user's context only.

  2. Which Dataverse message runs a Power Platform prompt from code?

    Show answer

    Predict.

  3. Which harness does the Copilot Studio client library officially support?

    Show answer

    The standard harness.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz