Repository navigation
Allow assigning parent account roles to Foundry project identities - #18939
Open
Bhupesh Cholake (RealBhupesh) wants to merge 1 commit into
Open
Bhupesh Cholake (RealBhupesh) wants to merge 1 commit into
Bhupesh Cholake (RealBhupesh) wants to merge 1 commit into
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18939Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18939" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds opt-in parent-account RBAC assignments for Microsoft Foundry project managed identities.
Changes:
- Adds C# and ATS role-assignment APIs.
- Generates scoped Bicep role assignments and tests their output.
- Updates Foundry User terminology and Memory documentation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
ProjectResourceTests...verified.bicep |
Captures generated RBAC infrastructure. |
ProjectResourceTests.cs |
Tests project role assignments. |
HostedAgentExtensionTests.cs |
Updates Foundry User expectations. |
README.md |
Documents the Memory scenario. |
ProjectResource.cs |
Stores requested parent roles. |
ProjectBuilderExtension.cs |
Adds APIs and Bicep generation. |
HostedAgentBuilderExtension.cs |
Updates hosted-agent role terminology. |
AzureHostedAgentResource.cs |
Renames the role constant. |
FoundryRole.cs |
Adds ATS-compatible role mapping. |
FoundryExtensions.cs |
Reuses centralized role conversion. |
| Name = BicepFunction.CreateGuid(account.Id, project.Id, roleDefinitionId), | ||
| Scope = new IdentifierExpression(account.BicepIdentifier), | ||
| PrincipalType = RoleManagementPrincipalType.ServicePrincipal, | ||
| PrincipalId = projectPrincipalId, |
| var roleDefinitionId = BicepFunction.GetSubscriptionResourceId("Microsoft.Authorization/roleDefinitions", role.Id); | ||
| var roleAssignment = new RoleAssignment(Infrastructure.NormalizeBicepIdentifier($"{prefix}_{role.Name}")) | ||
| { | ||
| Name = BicepFunction.CreateGuid(account.Id, project.Id, roleDefinitionId), |
| var subscriptionResourceId = provisioningContext.Subscription.Id.ToString(); | ||
| var roleDefinitionId = new ResourceIdentifier( | ||
| $"{subscriptionResourceId}/providers/Microsoft.Authorization/roleDefinitions/{AzureAIUserRoleDefinitionId}"); | ||
| $"{subscriptionResourceId}/providers/Microsoft.Authorization/roleDefinitions/{FoundryUserRoleDefinitionId}"); |
| /// <param name="roles">The Microsoft Foundry roles to assign to the project identity.</param> | ||
| /// <returns>The resource builder.</returns> | ||
| /// <ats-returns>The resource builder.</ats-returns> | ||
| [AspireExport("withFoundryProjectRoleAssignments")] |
| /// .WithRoleAssignments(foundryUserRole); | ||
| /// </code> | ||
| /// </example> | ||
| [AspireExportIgnore(Reason = "CognitiveServicesBuiltInRole is an Azure.Provisioning type not compatible with ATS. Use the FoundryRole-based overload instead.")] |
|
|
||
| Some Foundry features call other services through the project's managed identity. Assign the required role on the parent Foundry account directly to that identity: | ||
|
|
||
| ```csharp |
Author
|
@microsoft-github-policy-service agree |
Bhupesh Cholake (RealBhupesh)
marked this pull request as ready for review
July 30, 2026 18:06
Bhupesh Cholake (RealBhupesh)
requested a review
from Sébastien Ros (sebastienros)
as a code owner
July 30, 2026 18:06
This branch has not been deployed
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.
Description
Add a project-specific
WithRoleAssignmentsoverload that grants Cognitive Services roles on the parent Microsoft Foundry account to the Foundry project's own managed identity.Foundry features such as Memory authenticate through the project's managed identity. The existing generic role-assignment path only grants permissions to resources that reference a target, so calling it on a Foundry project did not emit a role assignment. Using the raw Foundry User GUID in a manual workaround could also produce an invalid Bicep identifier.
This change:
AzureCognitiveServicesProjectResourceThe API is explicit and opt-in. It does not broaden the default permissions assigned to Foundry projects.
Fixes #18938
Addresses #10871
Validation
Aspire.Hosting.Foundry.Tests: 119 passedAspire.Hosting.Foundry.Tests.csprojbuild: succeeded with 0 warnings and 0 errorsdotnet format --verify-no-changes: passed for the changed C# filesgit diff --check: passedChecklist
<remarks />and<code />elements on your triple slash comments?The security-sensitive behavior is limited to explicit role requests. The generated assignment uses the requested built-in role, the project's managed identity, and the parent Foundry account scope.