Add operator role assignment support for Azure resources #12117
+409
−1
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.
Overview
This PR implements a new feature that allows Azure Container Apps environments to designate operator principals (users or groups) that should receive administrative access to Azure resources. This addresses scenarios where users deploying Aspire applications to Azure lack administrative access to resources and need to manually configure role assignments.
Problem
When deploying Aspire-based applications to Azure using Azure Container Apps, users often don't have administrative access to the deployed resources. This requires them to:
Solution
This PR introduces a declarative programming model that allows resources to define "operator roles" and compute environments to designate operator principals. The system automatically generates the appropriate role assignments during deployment.
Usage Example
Generated Bicep
The system generates role assignment resources like this:
Implementation Details
New Annotations
OperatorPrincipalAnnotation: Applied to compute environments to store operator principal IDsOperatorRoleCallbackAnnotation: Applied to Azure resources to define which roles operators should receiveAPI Surface
WithOperator(IResourceBuilder<ParameterResource>): Extension method onIResourceBuilder<AzureContainerAppEnvironmentResource>to add operator principalsInfrastructure
ProcessOperatorRoleAssignments(): New method inAzureResourcePreparerthat processes operator annotations and creates role assignment resources during theBeforeStartAsynclifecycle hookIAddRoleAssignmentsContextfor consistencyResource Integration
StorageAccountContributorrole for operatorsTesting
Added comprehensive test suite (
OperatorRoleAssignmentTests.cs) with 6 tests covering:All tests pass successfully.
Future Enhancements
The implementation provides a foundation for:
Breaking Changes
None. This is a new feature that doesn't affect existing functionality.
Related Issues
Addresses the operator role assignment feature request for Azure-based deployments.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/usr/local/bin/bicep build /tmp/aspire8yc1IN/env.module.bicep --stdout(dns block)/usr/local/bin/bicep build /tmp/aspireDquH6I/env.module.bicep --stdout(dns block)/usr/local/bin/bicep build /tmp/aspiretha8PR/internal-api.module.bicep --stdout(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.