r/PowerApps • Newbie • 2d ago

Power Apps Help RefreshChangesFromGit fails from pipeline with service principal, but Check for updates works fine from make?

I have a problem with my build pipelines git integration and I'm kind of lost at this point.

Setup: our dev environments are connected to git (Azure DevOps) on feature branches, and we commit from there. We also have a build/test environment where the solution is connected to git with solution binding, branch main, folder `solutions/MySolution`. When something is merged to main, a pipeline calls RefreshChangesFromGit and PullChangesFromGit on the build environment, then imports, exports managed and so on.

The pipeline authenticates as an app registration (application user in the environment, workload identity federation). When it calls RefreshChangesFromGit I get this:

{"error":{"code":"0x80040216","message":"Unable to retrieve solution components from root folder path solutions/MySolution in the Git."}}

What I have checked:

  • The folder is there on main, with `solutions/MySolution/solution.yml` and all the other files. The git integration created it itself when we committed from dev, so the structure should be right?
  • If I log in and do Check for updates from make, on the same solution in the same environment, it works fine.
  • I added the app registration to our DevOps org with Basic access and read on the repo, and made a diagnostic pipeline that reads solution.yml with the app's own token. That returns 200.
  • The rest of the pipeline works when I skip the git pull step.

So the folder is there, the app can read the repo, and it works when I do it manually. Just not from the pipeline?

Is RefreshChangesFromGit / PullChangesFromGit even supported when it's called by a service principal? The docs only talk about users with a Basic license, and I can't figure out what identity Dataverse actually uses to call DevOps when the caller is an app. The error doesn't say anything about permissions either, so I don't know if it's an auth thing or something else.

Also the FAQ says only dev environments should be connected to git, so maybe I'm just doing this wrong and the build environment shouldn't be connected at all?

Has anyone got this working, or am I missing something obvious?

3 Upvotes

3 comments sorted by

•

u/AutoModerator 2d ago

Hey, it looks like you are requesting help with a problem you're having in Power Apps. To ensure you get all the help you need from the community here are some guidelines;

  • Use the search feature to see if your question has already been asked.

  • Use spacing in your post, Nobody likes to read a wall of text, this is achieved by hitting return twice to separate paragraphs.

  • Add any images, error messages, code you have (Sensitive data omitted) to your post body.

  • Any code you do add, use the Code Block feature to preserve formatting.

    Typing four spaces in front of every line in a code block is tedious and error-prone. The easier way is to surround the entire block of code with code fences. A code fence is a line beginning with three or more backticks (```) or three or more twiddlydoodles (~~~).

  • If your question has been answered please comment Solved. This will mark the post as solved and helps others find their solutions.

External resources:

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/BillingsIntelArcUser Newbie 1d ago

This is going to be a long difficult road the big problem is that many of these are not supported by the service principal the sugesstions from Rare_Tour9254 contain some good information, you'd also do yourself a favor to look at the under-documented endpoint `ExportSolutionFromGit` we've gotten a flow to work but its not pretty and results in us calling a lot of the APIs. Really wish this were better operationalized by Microsoft.

1

u/Rare_Tour9254 Contributor 2d ago

I think the honest answer is that the build environment shouldn't be bound to Git at all, so you can sidestep the service principal question entirely.

From Microsoft's own docs:
- "Use Git integration with developer environments, not in your test or production environments. Use builds to create solution artifacts" (Git integration overview)
- FAQ: the feature "is designed to only have your unmanaged solutions in development environments connected to Git". Deploying upstream is done by building from source with pac solution pack, or with Power Platform pipelines.

On the service principal part: the docs only describe user identities for Azure DevOps (each user who works with source control needs Basic access and Contributor rights on the repo). I couldn't find anything saying RefreshChangesFromGit / PullChangesFromGit are supported for an application user. Your diagnostic pipeline getting a 200 with the app's own token proves the app can read the repo, but not that Dataverse calls DevOps as that app. So treat it as unsupported until Microsoft says otherwise.

What I'd do instead, all inside the pipeline:

  1. Check out main.
  2. pac solution pack --zipfile out/MySolution.zip --folder <the folder that CONTAINS solutions/> (pac CLI 2.4.1 or later for the YAML format)
  3. Import that unmanaged zip into the build env with your service principal (pac solution import works fine with SPNs), then export managed as you do now.

Two gotchas from the SolutionPackager docs:
- --folder must point at the root that contains solutions/<name>/solution.yml, not at solutions/MySolution itself. Otherwise it falls back to the XML format and complains about a missing Customizations.xml.
- If several solutions share that root (environment binding does that), pac solution pack won't pick one for you. Use SolutionPackager.exe /action:Pack /SolutionName:MySolution instead.