Power Apps code apps tutorial: build, run and publish your first app
Build your first Power Apps code app with the pa CLI: a React app run locally, wired to Office 365 Users and Dataverse, published, shared and kept in a solution.
Power AppsFix a problem29 min read
This Power Apps code apps tutorial is for developers who know a little React and TypeScript and want their app to run inside Power Platform, with its sign-in, connectors and governance, instead of on a server they look after themselves. By the end you'll have a React and TypeScript code app that runs on your machine, reads data through Office 365 Users and Dataverse, is published to an environment, is shared with colleagues, and sits in a solution, ready to move to test and production.
A code app is a single-page web app that you write in your own editor and publish with the Power Apps command-line tool, pa. Power Apps hosts the built files, signs users in with Microsoft Entra ID, and lets your code call connectors through generated TypeScript services. Learn says code apps follow your organisation's Power Platform policies, such as sharing limits, Conditional Access and data loss prevention. If you're still deciding whether you need one, read code apps vs canvas apps first.
- Step 1Turn on code apps
- Step 2Get the template
- Step 3pa app init
- Step 4Run it in Local Play
- Step 5Add data sources
- Step 6Build and pa app push
- Microsoft Power AppsOpen it in Power Apps
- Step 8Share it
What changed in 2026, in one paragraph
Code apps became generally available on 5 February 2026. The tooling then changed: the commands moved from pac code in the Power Platform CLI to a separate npm package, @microsoft/power-apps-cli, whose command is pa. It reached version 1.0.0 on 19 August 2026, and version 1.4.1 was published on 4 November 2026. Microsoft hasn't posted release notes for versions 1.1 to 1.4.1 (there's no GitHub release or announcement for them as of 10 November 2026), so the pa commands below follow the current Learn command reference, dated 2 October 2026, unless the text names another source. Microsoft labels pac code as preview and says the npm CLI will replace it. If a video or blog post tells you to run pac code init, it's from the older toolchain; see the command map at the end.
What you need before you start
Tools on your computer
- Node.js 22 or later. Learn's quickstart asks for the current LTS release, and the
@microsoft/power-apps-cli1.4.1 package itself declares Node.js 22 or later. Check withnode --version. - Git, and any editor. Visual Studio Code works well, but nothing in the flow needs a particular editor or extension.
- The Power Apps CLI (
pa). You install it in step 2. You don't need the Power Platform CLI (pac) for this flow; Learn's prerequisites don't list it. - A browser profile signed in to your work tenant. You'll open your local app in that same profile.
An environment with code apps turned on
An admin turns the feature on per environment. Power Platform admins and environment admins can both do it:
- Sign in to the Power Platform admin center.
- Go to Manage > Environments and select the environment.
- Select Settings, expand Product, then select Features.
- Find Power Apps code apps and turn on Enable code apps.
- Select Save.
To set it on many environments at once, Microsoft points admins to environment groups and rules. Turn it on in every environment the app will reach, including test and production, before you deploy a solution there.
Pick a sandbox or a developer environment for this tutorial, not the default environment. Two reasons: Learn's ALM guidance moves an app from development through test to production, so it helps to start in a development environment, and the default environment's ID starts with default-, which you must type in full (more in Troubleshooting). From 15 November 2026, Microsoft doesn't let anyone create unmanaged developer environments; you can still create one managed developer environment per user, or use a sandbox.
You also need Dataverse in the environment if you want step 6 (Dataverse data) and step 10 (solutions). Without Dataverse, the app publishes without a solution.
Licences for the people who use it
Every person who runs a code app needs one of the options Learn lists: a Power Apps Premium licence, pay-as-you-go turned on, an App Pass, or auto-claim turned on (which hands out a Premium licence automatically if the tenant has one free). That's true whatever connectors the app uses, even Office 365 Users or SharePoint. Learn lists no Microsoft 365 option. For the detail and current prices, see code apps limitations and licensing and Power Apps licensing explained.
Warning
Before you roll out, test with an ordinary user account that has only the licences your users have, so any licence prompt shows up for you first.
Step 1: Get the template
Microsoft keeps its templates in the PowerAppsCodeApps repository on GitHub. Learn's quickstart uses the minimal Vite template. degit copies a folder from GitHub without its Git history:
npx degit github:microsoft/PowerAppsCodeApps/templates/vite my-app
cd my-app
What you should see: a new my-app folder with a React, TypeScript and Vite project. Its vite.config.ts already loads Microsoft's powerApps() Vite plugin, and package.json already lists the client library, @microsoft/power-apps.
There are two templates, and they differ only in what comes preinstalled:
| Template | What's in it | When to pick it |
|---|---|---|
vite | React, TypeScript, Vite and the Power Apps plugin, nothing more | Learning, or when you want to choose every library yourself. Learn's quickstart uses it. |
starter | The same base plus Tailwind CSS, TanStack Query and React Router | Most real apps. The repository's README marks it as recommended. |
To use the starter instead, replace vite with starter in the path. Every later step is the same.
Tip
Start from one of Microsoft's templates rather than a Vite project you made yourself. The templates come wired to the Power Apps plugin and client library, so there's less to get wrong.
Step 2: Install the CLI and initialise the app
Install the Power Apps CLI and the client library globally, then the project's own packages. These are the three commands Learn's quickstart runs:
npm install --global @microsoft/power-apps-cli
npm install --global @microsoft/power-apps
npm install
Check what you got:
pa --version
Now link the folder to your environment. The simplest way is to answer the prompts:
pa app init
The CLI asks you to sign in if you aren't signed in yet, then prompts for the values you didn't pass. To do it in one line instead, pass the display name and the environment:
pa app init --display-name "Team Directory" --environment-id <environment-id>
Your environment ID is the value after /environments/ in the address bar when you're in Power Apps with that environment selected.
What it created: a power.config.json file in the project root. Among other settings it holds the environment ID, the region, the app type and localAppUrl, the address of your local dev server (http://localhost:3000 unless you passed --app-url). The CLI and the client library read this file; your own code never needs to. Other options you might want later are --description, --build-path (default ./dist) and --file-entry-point (default index.html).
Tip
If you belong to more than one tenant, check which account the CLI is using with pa auth status, and change it with pa auth switch. pa auth logout signs you out of every account at once.
Step 3: Run it locally in Local Play
Start the Power Apps local host:
pa app run
What you should see: the terminal prints a URL labelled Local Play. Open it in the same browser profile you use for your tenant. Your app loads inside the Power Apps host, which signs you in, so the connections you add later are your own. The local host listens on port 8080 by default; change it with --port.
Chrome and Microsoft Edge block public websites from calling addresses on your own machine by default. Because Local Play is a Power Apps page talking to your localhost, the browser may show a local network access prompt. Allow it. If your organisation manages the browser, an admin may need to allow it by policy.
Note
Microsoft's pages describe two ways to start local development. Learn's quickstart uses pa app run, which Learn describes as starting the Power Apps local host; its --local-app-url option is the address of your locally running app, and Learn doesn't say whether pa app run also starts your dev server. The Connect to data page and the repository's README use npm run dev instead, and the README of Microsoft's Vite plugin says the dev server then prints a Local Play URL of its own. If Local Play opens but your app's page doesn't load, start your dev server with npm run dev in a second terminal and check that it runs at the address saved as localAppUrl in power.config.json.
Step 4: Add Office 365 Users as your first data source
A code app reaches data through connections. A connection is your signed-in link to one connector, such as Office 365 Users. You create the connection, then add it to the app as a data source. Run these from the project root, after pa app init.
Find the connector's identifier:
pa connector list --search office
The output has a Display Name column and a Connector column. Find the Office 365 Users row: its identifier is shared_office365users.
Create a connection to it:
pa connection create --connector shared_office365users
What you should see: the command returns the new connection's ID. Copy it. If you lose it, pa connection list shows your connections with their IDs. You can also create connections in Power Apps if you prefer.
Add the connection to your app:
pa app add data-source --connector shared_office365users --connection-id <connection-id>
What it created:
src/generated/models/Office365UsersModel.ts: TypeScript types for the connector's requests and responses.src/generated/services/Office365UsersService.ts: a service with one method per connector action.- Schema files under
.power/schemas/, and a new data source entry inpower.config.json.
Office 365 Users only has actions, so it needs no table or dataset. Leave out the options and run pa app add data-source on its own if you'd like the CLI to prompt you for each value instead.
Step 5: Call the generated service from React
Learn's example for this connector calls MyProfile_V2 with a comma-separated list of the fields it wants, and reads the profile from the result's data property. The connector's reference lists id, displayName, jobTitle and userPrincipalName among the fields that action returns. Here's that pattern as a small component. It takes the profile's type from the generated service instead of naming a model type, so it matches whatever your CLI version generated. Save it as src/MyProfile.tsx:
import { useEffect, useState } from "react";
import { Office365UsersService } from "./generated/services/Office365UsersService";
type Profile = Awaited<ReturnType<typeof Office365UsersService.MyProfile_V2>>["data"];
export function MyProfile() {
const [profile, setProfile] = useState<Profile>();
const [error, setError] = useState<string | null>(null);
useEffect(() => {
Office365UsersService.MyProfile_V2("id,displayName,jobTitle,userPrincipalName")
.then((result) => setProfile(result.data))
.catch(() => setError("We couldn't load your profile."));
}, []);
if (error) return <p role="alert">{error}</p>;
if (!profile) return <p>Loading your profile…</p>;
return (
<section aria-labelledby="profile-heading">
<h2 id="profile-heading">{profile.displayName}</h2>
<p>{profile.jobTitle}</p>
<p>{profile.userPrincipalName}</p>
</section>
);
}
Then import it in src/App.tsx and render <MyProfile /> wherever you want it.
This follows Microsoft's documented pattern; we haven't run it in a tenant. The exact method names and types come from the files the CLI generated for you, so open Office365UsersService.ts and Office365UsersModel.ts to see what your version offers. Your editor's autocomplete reads the same files.
What you should see: refresh Local Play, and the page should show your name and job title. The first time the app uses a connection, Power Apps shows a consent dialog asking you to allow it. Select Allow. Your users will see the same dialog the first time they open the app, unless an admin suppresses it.
Note
You don't write any sign-in code. The Power Apps host signs the user in, and the generated service calls the connector with that user's connection.
Step 6: Add Dataverse (or a SharePoint list)
This tutorial uses Dataverse for the second source. Dataverse is "native" in code apps: it needs no connection ID, just the table's logical name. This adds the standard Account table:
pa app add data-source --connector dataverse --table account
If you don't pass --org-url with your environment's Dataverse address (it looks like https://yourorg.crm.dynamics.com), the CLI asks for it in an interactive terminal. You can add one Dataverse table per command.
What it created: a model and a service for the table (Learn's example names them AccountsModel.ts and AccountsService.ts in src/generated/), plus the schema and power.config.json entries. The service has create, get, getAll, update and delete.
Read the first ten accounts by name. Microsoft's advice is to always name the columns you need with select. The list includes accountid, the table's primary key, so each item has a key:
import { useEffect, useState } from "react";
import { AccountsService } from "./generated/services/AccountsService";
import type { Accounts } from "./generated/models/AccountsModel";
export function AccountList() {
const [accounts, setAccounts] = useState<Accounts[]>([]);
useEffect(() => {
AccountsService.getAll({
select: ["accountid", "name", "accountnumber"],
orderBy: ["name asc"],
top: 10,
})
.then((result) => setAccounts(result.data ?? []))
.catch(() => setAccounts([]));
}, []);
return (
<ul>
{accounts.map((account) => (
<li key={account.accountid}>{account.name}</li>
))}
</ul>
);
}
getAll also takes filter (an OData filter string), skip, skipToken and maxPageSize. Per Learn, filter, sort and top run on the server (they're delegated), and paging is supported. When you update a record, send only the columns you changed; Learn warns that sending unchanged values can trigger business logic and muddy the audit history.
What Dataverse can't do in code apps yet, per Learn (November 2026): polymorphic lookups, FetchXML, alternate keys, and creating or changing table definitions. Lookups work through Web API association patterns for now. File and image upload and download is in preview.
The SharePoint version
A SharePoint list needs a connection, the site URL as the dataset and the list name as the table:
pa connection create --connector shared_sharepointonline
pa connection list-tables --connector shared_sharepointonline --connection-id <connection-id> --dataset "https://contoso.sharepoint.com/sites/Travel"
pa app add data-source --connector shared_sharepointonline --connection-id <connection-id> --dataset "https://contoso.sharepoint.com/sites/Travel" --table "<list-name>"
Replace <list-name> with the name exactly as list-tables prints it: names are case-sensitive and can contain special characters (Learn's own example passes a list name with its space written as %20). SharePoint offers both tables and actions, so if you leave out --table the CLI asks Add a table?, and in a pipeline it fails until you pass --as table or --as action. For choice, lookup and person columns, the generated service has getReferencedEntity() to fetch the allowed values.
Step 7: Build and push
Build the app:
npm run build
The template's build script runs the TypeScript compiler before Vite, so a type error that the dev server let through stops the build here. Fix it and build again.
What it created: the compiled app in dist/. That folder is what gets published.
Publish it:
pa app push
What you should see: the CLI reports which solution it put the app in (or why it didn't use one), then prints a Power Apps URL where the app runs. Each push publishes a new version; to change the app later, change the code, build and push again.
Where the app lands on its first push, per Learn's ALM page:
- the environment's preferred solution, if Dataverse is on. If nobody set one, that's the Common Data Service Default Solution;
- otherwise the all-components Default solution;
- no solution at all if the environment has no Dataverse.
Later pushes leave the app in whatever solution it's already in, unless you name one. Step 10 shows how.
Tip
Set a preferred solution in the environment before your first push, and the app goes straight into the solution you'll deploy from. It's the simplest way to avoid hunting for the app in the Default solution later.
Step 8: Open the app
You can open it two ways:
- From the terminal: open the URL that
pa app pushprinted. - From Power Apps: go to make.powerapps.com, select the environment, open Apps, and find the app by its display name. From there you can play it, share it and view its details.
Copy the address from the push output or the browser rather than building it by hand: Learn's pages show more than one format for a code app's play address. To hide the Power Apps header bar for everyone, run pa app set-setting --show-header false, then push again.
Note
Where code apps run, as of November 2026: in a web browser, yes. Learn says they aren't supported in Power Apps for Windows. Learn no longer lists the Power Apps mobile app as unsupported, and a Microsoft maintainer wrote in GitHub discussion #474 (October 2026) that code apps run online in the mobile app. Learn doesn't yet say so itself, so test on your users' devices. In the same thread the maintainer said offline support isn't planned for the immediate future.
Step 9: Share it
Share from the CLI. The app must have been pushed at least once, because sharing needs the app ID that the first push creates:
pa app share --principal alex@contoso.com,sam@contoso.com --access play
--principal takes email addresses or Microsoft Entra object IDs, separated by commas. --access is play (the default) or edit.
Or share from Power Apps: select Apps, select the app, and use Share. For canvas apps, Microsoft recommends sharing with a security group once you're sharing with more than 100 users; Learn's code apps pages don't say whether the same advice applies, so check what the share panel offers you. Learn does say that code apps follow canvas app sharing limits.
Sharing the app doesn't share the data. Before people can use it:
- Office 365 Users: each person uses their own connection, created for them through the consent dialog the first time they open the app.
- Dataverse: each person needs a security role that lets them read (and, if your app writes, change) the Account table. Ask your admin if you can't assign roles.
- SharePoint: each person needs access to the list itself.
- Licences: each person needs one of the premium options in Licences for the people who use it.
Tip
The npm package's README (November 2026) documents a newer setting that Learn's command reference doesn't list yet: you can customise the title and message of the dialog people see when they need to request access, with pa app set-setting --customize-request-access true --request-access-title "..." --request-access-message "...", then pa app push.
Step 10: Keep it in a solution
A solution is what moves the app from development to test and production. If the first push didn't put it in the right one, you have two options.
From the CLI. List your solutions to get the ID, then push with it:
pa solution list
pa app push --solution-id <solution-id>
--solution-id (short form -s) needs the solution's GUID; names aren't accepted. You can also find the GUID in the address bar when a solution is open in Power Apps. Passing it on a later push adds the app to that solution too. In a pipeline, set the PA_CLI_SOLUTION_ID environment variable instead.
From Power Apps. Open Solutions, select the solution, then Add existing > App > Code app, and choose your app.
Once it's in a solution, use Power Platform Pipelines to deploy from development to test to production. For each data source, bind the app to a connection reference in the solution rather than your personal connection, so each environment supplies its own connection. Get the reference's logical name with pa connection list-references --solution-id <solution-id>, then add the data source with --connection-ref <logical-name> --solution-id <solution-id> in place of --connection-id.
Warning
The solution holds only the built app, not your source code, and Learn says code apps don't support Power Platform Git integration. Your own Git repository is the only copy of the source. Commit and push it before you deploy anything.
What's in the project folder
| Path | What it is | Edit it? |
|---|---|---|
src/ | Your React and TypeScript code | Yes |
src/generated/models/ and src/generated/services/ | Typed models and services the CLI writes for each data source | No. Regenerate them with the CLI. |
.power/schemas/ | Connector schemas and data source details the CLI keeps | No |
power.config.json | Environment, app settings and data source bindings | No. The CLI manages it. |
dist/ | The build output that pa app push uploads | No. npm run build recreates it. |
vite.config.ts | Vite settings, including the powerApps() plugin | Carefully |
package.json | Your dependencies, including @microsoft/power-apps | Yes |
A repository collaborator whose GitHub profile lists Microsoft said in GitHub issue #402 (July 2026) that power.config.json is managed by the CLI and shouldn't be edited by hand. In that thread, a hand-edited connection setting stopped other users from completing consent. To change a data source, use the CLI:
pa app refresh data-source --name <data-source-name>
pa app remove data-source --connector <connector-id> --name <data-source-name>
Refresh after the source's schema changes; remove and add again to switch connections.
Good habits, and where each comes from
- Route on the client, with hash or query-based routing. Learn says code apps support single-page apps. In GitHub issue #192 (February to March 2026), a commenter who identified as a Microsoft engineer in issue #187 said code apps don't support server-side rendering at this time, that hash routing worked in their experience, and that the starter template uses a query-based router, with changes so the app doesn't land on a 404 at launch. No Learn page covers routing.
- Call outside services through connectors, not
fetch. Code apps enforce a Content Security Policy by default, and itsconnect-srcdirective is'none': the browser blocks direct calls to other origins. Use a connector, or a custom connector in front of your own API. An environment admin can allow specific origins under Settings > Product > Privacy + Security > Content security policy > App in the admin center (for an environment with Dataverse; otherwise through the Power Platform API). - Don't add your own MSAL sign-in. In GitHub issue #187 (February 2026), a commenter who identified as a Microsoft engineer said using MSAL in code apps isn't supported; no Learn page covers it. The host signs users in; connectors carry their identity.
- Keep secrets and sensitive data out of the bundle. Learn says the built files are served from a publicly reachable endpoint with no IP restriction. Fetch sensitive data from a data source after sign-in, and use Conditional Access to restrict by location.
- Use environment variables for site and list addresses. Pass
@envvar:<schema-name>to--datasetor--tableand the app resolves the value in each environment, so the same build works in development, test and production. - Record and control your versions. Note
pa --versionand your@microsoft/power-appsversion; Microsoft asks for the CLI version when you report a problem. Update them on purpose, one at a time, and check the repository's announcements and closed issues when something breaks after an update. - Script your CLI calls for pipelines. For unattended publishing, Learn documents a service principal with edit access and
pa app push --non-interactive. In non-interactive mode,pa app add data-sourcealso needs--asfor connectors that offer both tables and actions.
Optional: build it with an AI coding agent
Microsoft publishes a code apps plugin for coding agents in its power-platform-skills repository. As of 10 November 2026, the plugin is code-apps-preview, version 1.3.0, labelled preview, and it needs Node.js 22 or later. Its skills are /create-code-app, /add-datasource, /add-dataverse, /add-connector and /deploy.
Install it in Claude Code:
claude plugin install code-apps-preview --marketplace microsoft/power-platform-skills
Or in the GitHub Copilot CLI:
copilot plugin marketplace add microsoft/power-platform-skills
copilot plugin install code-apps-preview@power-platform-skills
Learn's Copilot quickstart (June 2026) describes the flow: you describe the app and your environment, the agent checks prerequisites, proposes a plan for you to approve, then runs the code apps CLI to build and deploy the app. In that quickstart you add the marketplace and install the plugin from inside a Copilot session, with /plugin marketplace add microsoft/power-platform-skills and /plugin install code-apps-preview@power-platform-skills. That quickstart names the skill /code-apps-preview:create-app, while the newer plugin page lists /create-code-app; use whatever your installed version shows.
Before you rely on it:
- It's preview, and Microsoft says it may change before general availability.
- The agent runs commands with your signed-in account. Read the plan before you approve it.
- Set a preferred solution first. The agent publishes with the same CLI, so its first push follows the same solution rules as step 7.
- Review the generated code like any pull request, and ask for accessibility explicitly: keyboard use, labels and focus order.
Troubleshooting
Each entry says where the fix is confirmed: on Microsoft Learn, or in Microsoft's PowerAppsCodeApps GitHub repository.
Push says the environment doesn't allow code app operations
- The error says the environment doesn't allow this operation for this code app, and asks you to contact your admin to enable code app operations.
Cause: code apps aren't turned on in that environment, or the CLI is pointed at a different environment from the one you think. Fix: turn on Enable code apps as in What you need before you start, and compare environmentId in power.config.json with the environment you meant. Confirmed: Learn documents the setting. The error text comes from one user report on Reddit in September 2025, made with the older pac code push; no Microsoft page shows it, and we found no report of it with pa.
pa app add data-source fails with Fetch Failed, ETIMEDOUT, ENOTFOUND or ECONNRESET
Cause: usually your network or sign-in, not your code. Fix: check that power.config.json has the right environmentId and "region": "prod", run pa auth status to confirm the active account, and check you can open the data source in a browser with that account. A 401 or 403 in a traffic capture means permissions. Confirmed: Learn, "Troubleshoot adding a data source".
TypeError: fetch failed, Request failed: {} or SELF_SIGNED CERT IN CHAIN on a corporate network
Cause: a proxy that inspects TLS, such as Zscaler, swaps in its own certificate, and Node.js doesn't trust it. If the command works off the corporate network, this is likely it. Fix: export your proxy's root certificate to a PEM file and point the NODE_EXTRA_CA_CERTS environment variable at it, then reopen your terminal. Learn's page has the PowerShell for it, and for other proxy products. If it works only outside the VPN, ask your network team to allow *.powerplatform.com, *.dynamics.com and *.azure.net on port 443. Never leave NODE_TLS_REJECT_UNAUTHORIZED=0 set. Confirmed: Learn, "Troubleshoot Power Apps CLI issues with Zscaler".
getaddrinfo ENOTFOUND in the default environment
Cause: the default environment's ID includes the default- prefix, and it was left out. Fix: use the full ID, prefix included, or build in another environment. Confirmed: Microsoft in GitHub issue #472 (October 2026, still open).
Local Play opens but stays blank, or shows AppLoadFailed and "Code app URL is not available"
Check three things, in this order:
- The browser blocked localhost. Look for the local network access prompt and allow it. Confirmed: Learn quickstart.
- The wrong browser profile. Open Local Play in the profile signed in to your tenant. Confirmed: Learn quickstart.
- A service-side feature gate. In October 2026,
AppLoadFailedwith "Code app URL is not available" hit Local Play in several regions. A repository collaborator said on 22 October that the cause, a feature gate, had been switched off, that the real fix would follow "in several weeks", and that the gate would come back on after that. If the error returns, check that issue and the repository's open issues before you change anything in your app. Confirmed: in GitHub issue #504 (October 2026, closed).
Other users get an internal server error at the consent dialog
- You can open the app, but a colleague sees "Encountered internal server error" when the player tries to create their connection, and Allow is greyed out.
Cause: someone edited power.config.json by hand to pin a connection, which skips each user's own connection. Fix: remove the data source and add it again with pa app add data-source, so each user binds their own connection through consent. Confirmed: a repository collaborator whose GitHub profile lists Microsoft, in GitHub issue #402 (July 2026).
The browser console says a request "violates the following Content Security Policy directive"
Cause: your code called another website directly, and the default connect-src 'none' blocked it. Fix: call it through a connector or a custom connector, or ask an environment admin to add that origin to connect-src on the Content security policy App tab. Confirmed: Learn, "Configure Content Security Policy".
The app shows a 404 page at launch after you add a router
Cause: the router has no route for the address the app opens at, so it shows its not-found page. Fix: use hash routing, or a query-based router whose home route is the default rather than a 404 page, as the starter template does. Confirmed: a commenter who identified as a Microsoft engineer, in GitHub issue #192 (February to March 2026); no Learn page covers it.
pa app add data-source fails in a pipeline but works on your machine
Cause: for connectors such as SharePoint and SQL Server, the interactive command asks Add a table?; without a terminal it can't. Fix: pass --as table or --as action. Confirmed: Learn command reference.
An Excel Online connector won't work
Cause: Excel Online (Business) and Excel Online (OneDrive) are the two connectors Learn lists as not yet supported in code apps. Fix: keep the data in SharePoint, Dataverse or SQL instead. Confirmed: Learn, "Connect your code app to data".
Sign-in redirect errors after you added MSAL
Cause: your own MSAL sign-in. A commenter who identified as a Microsoft engineer said MSAL isn't supported in code apps; no Learn page covers it. Fix: remove it and use connectors; the host handles sign-in. Confirmed: a commenter who identified as a Microsoft engineer, in GitHub issue #187 (February 2026).
If you report a bug, Learn asks for the output of pa --version, your operating system and shell, the full command, the sanitised error and your power.config.json with sensitive values removed. Search the repository's closed issues first; Learn's overview recommends it, to see how others solved a problem and whether a fix is already available.
If you follow an older tutorial
Videos and posts from 2025 and early 2026 may use the Power Platform CLI's pac code commands, or an interim power-apps command that Microsoft removed when the pa CLI became generally available. The current equivalents:
| Older command | Current command |
|---|---|
pac auth create and pac env select | Sign-in happens in pa app init; pa auth login and pa auth switch |
pac code init --displayName "..." | pa app init --display-name "..." |
pac code run | pa app run |
pac code add-data-source -a <api> -c <connection> | pa app add data-source --connector <id> --connection-id <id> |
pac code delete-data-source | pa app remove data-source |
pac code push --solutionName <name> | pa app push --solution-id <GUID> |
Older guides also wait for an initialize() call before loading data. Client library 1.0 removed initialize(), and Microsoft's migration page says to delete those calls.
Sources
- Power Apps code apps overview — Microsoft Learn
- Quickstart: Create a code app using the Power Apps CLI — Microsoft Learn
- Power Apps CLI command reference — Microsoft Learn
- Power Apps CLI environment variables — Microsoft Learn
- Power Apps code apps architecture — Microsoft Learn
- Code apps system configuration — Microsoft Learn
- Sign in and manage accounts with the Power Apps CLI — Microsoft Learn
- Create a connection from the Power Apps CLI — Microsoft Learn
- Connect your code app to data — Microsoft Learn
- Connect your code app to Dataverse — Microsoft Learn
- SharePoint operations in code apps — Microsoft Learn
- Use environment variables in code app data sources — Microsoft Learn
- Application lifecycle management for code apps — Microsoft Learn
- Publish by using a service principal — Microsoft Learn
- Configure Content Security Policy for code apps — Microsoft Learn
- Migrate your code to client library v1.0 — Microsoft Learn
- Quickstart: Build a code app with GitHub Copilot — Microsoft Learn
- Embed a code app in an iframe — Microsoft Learn
- Office 365 Users connector reference — Microsoft Learn
- Troubleshoot adding a data source — Microsoft Learn
- Troubleshoot Power Apps CLI issues with Zscaler — Microsoft Learn
- Power Platform CLI pac code commands (preview) — Microsoft Learn
- Power Platform CLI pac auth commands — Microsoft Learn
- Power Platform CLI pac env commands — Microsoft Learn
- Share a canvas app with your organization — Microsoft Learn
- Deprecation of unmanaged developer environments — Microsoft Learn
- Generally available: host and run code apps in Power Apps — Microsoft Power Platform Blog
- microsoft/PowerAppsCodeApps repository, README and templates — GitHub
- Power Apps code apps npm-based CLI is now generally available, discussion #438 — GitHub
- Breaking change notice: generated file paths and names, discussion #149 — GitHub
- @microsoft/power-apps-cli package — npm
- @microsoft/power-apps-vite package — npm
- Vite features: TypeScript — Vite
- Code apps plugin (code-apps-preview) — Microsoft power-platform-skills
- Code apps on mobile and Windows, discussion #474 — GitHub
- Issue #504: Local Play AppLoadFailed — GitHub
- Issue #472: ENOTFOUND in the default environment — GitHub
- Issue #402: consent fails for non-owners after editing power.config.json — GitHub
- Issue #192: routing in code apps — GitHub
- Issue #187: MSAL in code apps — GitHub
- Power Apps CODE Apps full tutorial, a lead for the solution-first flow — Reza Dorrani, YouTube
- Code apps pac code push error, a lead for the enable-operations error — r/PowerPlatform, Reddit
Add LowCodeStacks as a preferred source on Google
Did this fix it?
Comments
No comments yet. Share what worked for you.
Sign in to comment. Comments show under a display name you choose, never your email.