Fix false "Private Access is not enabled" error when tenant has multiple forwarding profiles - #82
Merged
Thomas Detzner (tdetzner) merged 2 commits intoAug 13, 2026
Conversation
GET /beta/networkAccess/forwardingProfiles returns more than one profile per trafficForwardingType for tenants in the multiple-forwarding-profiles private preview. The feature-enablement checks assumed a single profile, so $paProfile.state enumerated to an array and the -ne 'enabled' array filter made the guard truthy, throwing even when the feature was enabled. Treat the result as a collection and pass when at least one profile of that traffic type is enabled. Applied to the Private Access config export, the Private Access app discovery export, and the Internet Access config export (all three had the same latent bug).
Thomas Detzner (tdetzner)
added a commit
that referenced
this pull request
Aug 13, 2026
There was a problem hiding this comment.
Pull request overview
Fixes false “feature not enabled” validation failures in the export cmdlets for tenants that return multiple forwarding profiles per trafficForwardingType. The previous guards assumed a single profile object; when multiple profiles existed, $profile.state enumerated and the -ne 'enabled' comparison produced a truthy array result, incorrectly throwing even when the feature was enabled.
Changes:
- Update Private Access config export to treat forwarding profiles as a collection and pass when at least one matching profile is
enabled. - Apply the same collection-based enablement check to Private Access app discovery export.
- Apply the same collection-based enablement check to Internet Access config export, and clarify the internal helper’s help text accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Migrate2GSA/internal/functions/Get-IntNetworkAccessForwardingProfile.ps1 |
Updates comment-based help to clarify that callers may receive multiple profiles per traffic type and should evaluate as a collection. |
Migrate2GSA/functions/GSA/Export-EntraPrivateAccessConfig.ps1 |
Fixes the Private Access enablement guard by checking for at least one enabled forwarding profile and improves diagnostic logging. |
Migrate2GSA/functions/GSA/Export-EntraPrivateAccessAppDiscovery.ps1 |
Fixes the Private Access enablement guard using the same “any enabled profile” logic. |
Migrate2GSA/functions/GSA/Export-EntraInternetAccessConfig.ps1 |
Fixes the Internet Access enablement guard using the same “any enabled profile” logic and improves diagnostic logging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On tenants enrolled in the multiple traffic forwarding profiles private preview,
Export-EntraPrivateAccessConfigfails during validation with:Private Access is enabled on the tenant — the validation is wrong.
Root cause
GET /beta/networkAccess/forwardingProfileshistorically returned exactly one profile pertrafficForwardingType. With the preview it returns a default profile plus up to 10 custom profiles per type.The enablement guards assumed a single profile:
With four
privateprofiles,$paProfileis an array. PowerShell then:$paProfile.stateinto@('enabled','disabled','disabled','disabled')— this is the space-mashed string visible in the error message,-neto that array, returning the 3 non-matching elements,Note this would throw even if all profiles were enabled, since a non-empty array is truthy either way.
Fix
Treat the result as a collection and pass when at least one profile of that traffic type is enabled:
Applied to all three call sites. The other two had the same latent bug and would have failed identically — Internet Access also gets multiple profiles in the preview, via the Fail-Close preview:
Export-EntraPrivateAccessConfigExport-EntraPrivateAccessAppDiscoveryExport-EntraInternetAccessConfigDiagnostics improved alongside: the failure message now lists each profile as
name: stateinstead of a space-mashed string, and the success line reportsN of M forwarding profile(s) enabled. The multi-profile return contract is now documented onGet-IntNetworkAccessForwardingProfile.Scope
This restores the on/off gate only. The exports still have no notion of which forwarding profile exposes which apps, so a preview tenant's profile topology is not captured and a restore would silently collapse every app into the default profile. That larger gap is tracked separately — see the companion docs PR and tracking issue.
Verification
pwsh scripts/verify.ps1passes: manifest valid, module imports cleanly, no Pester tests present.assistance: agentic-ide
type: bug
agent-tool: copilot-chat
agent-model: claude-opus-5
work-item: n/a