Posted in Code Apps

PAC CLI “Environment Not Found” – but the ID was correct?!

I hit a strange issue today while trying to spin up a Power Apps Code App from VS Code.

I was running:

npx power-apps init --display-name "<MY APP NAME>" --environment-id <env-id>

And got this error:

Environment '<env-id>' not found. Please verify the environment ID and ensure you have access to it.
Assertion failed: !(handle->flags & UV_HANDLE_CLOSING)

The confusing part?
– The environment ID was 100% correct
– It was working just a few hours earlier
– No changes on my device like updates or VS Code related changes

Initial troubleshooting

I went through the standard checklist:

  • Re-authenticated PAC CLI (multiple times)
  • Removed and recreated auth profiles
  • Reinstalled the Power Platform VS Code extension
  • Restarted VS Code and device
  • Double-checked PAC CLI version
  • Verified the environment ID
  • Google and AI search – which even pointed out to a known issue on specific PAC CLI versions, however that wasn’t the case for me

Nothing worked 😔

The real issue (multi-tenant gotcha)

After digging a bit deeper, I noticed something:

The Tenant ID was conflicting with my device / Organization Tenant.

  • My Dataverse Environment was in a separate Entra Tenant
  • However, PAC CLI was still authenticating against the corporate tenant (which my device is enrolled to)

So even though the environment ID was valid, it was being resolved in the wrong tenant, so PAC simply couldn’t find it.

Solution

The solution was to explicitly force the tenant during authentication:

pac auth create --tenant <DEV tenant>

After that:

pac auth select --index <profile>

Problem solved, now my pac code push worked just fine.

⚠️ NPX

I also noticed something else along the way.

The official docs often suggest using:

npx power-apps ...

However, this caused inconsistencies for me, especially in a multi-tenant setup.

  • npx
    • Spins up a separate Node process
    • Doesn’t always respect your existing PAC CLI auth context
    • Can default back to your “home” (corporate) tenant
  • pac
    • Uses your configured auth profiles
    • Keeps tenant context consistent
    • More reliable for day-to-day development

TL;DR

If your environment exists but PAC CLI says it doesn’t:

You’re probably in the wrong tenant
Fix it with:

pac auth create --tenant <correct tenant>

Hope this was helpful and keep Power Apps Coding.

Posted in Uncategorized

Power Pages – Power Apps Portals is now Power Pages

Microsoft Build 2022 is coming the announcements of many things throughout the Microsoft stack. I highly recommend catching-up on the sessions for your favourite topics here: https://mybuild.microsoft.com/en-US/home

Power Pages

Power Apps Portals is now Power Pages – and of course this is what I am here to talk about: Announcing Microsoft Power Pages: Build secure, low-code websites | Microsoft Power Pages

This is definitely the most exciting announcement for me personally. Microsoft has put a lot of investment on Power Apps Portals over the years and while it has been part of the Power Apps products for a few years, it is now becoming a product of its own within the Power Platform under the new name of Power Pages.

You may think this is just a product re-branding (as we all know Microsoft loves to do that), but it is a bit more than that, community forum will now have its own dedicated forum now, similar to Power BI or Power Automate, new Site Templates will be available to accelerate your implementation, a complete new Design Studio with many new capabilities and many more. I see all of this is a reflection of the growth of the platform and as a community member very much involved in this product, I am really happy to see this evolution.

What does this mean to your current Portals?

The base of the Portals is still the same, so there is no compatibility issue between them. Microsoft haven’t released yet details on migration, the only potential impact I can think of would be on the domain of your portals (from .powerappsportals.com to .powerpages.com). This should be more clear over the upcoming weeks.