-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add role assignments with .NET Aspire #2891
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice article. Reviewing this stuff continues to educate me on Aspire.
Approved to unblock, but some fixes required.
And don't forget to put the article in the TOC.
Co-authored-by: Andy (Steve) De George <[email protected]>
.WithReference(search); | ||
``` | ||
|
||
When you use the `WithRoleAssignments` method, it replaces the default role assignments with the specified ones. This method requires two parameters: the resource to which the role assignment applies and the built-in role to assign. In the preceding example, the `search` resource is assigned the <xref:Azure.Provisioning.Search.SearchBuiltInRole.SearchIndexDataReader?displayProperty=nameWithType> role. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the preceding example, the
search
resource is assigned the xref:Azure.Provisioning.Search.SearchBuiltInRole.SearchIndexDataReader?displayProperty=nameWithType role.
I would flip this wording. It isn't the search
resource that is assigned that role. Instead, the api
project is assigned that role to the search
resource.
For more information, see [.NET Aspire Azure App Container integration](../hosting/azure-app-container-integration.md). | ||
--> | ||
|
||
### Azure Application Insights |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support App Insights role assignments. We actually don't grant any right now, even by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
For more information, see [Azure built-in roles](/azure/role-based-access-control/built-in-roles). | ||
|
||
## Built-in role assignment reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not somewhere in Azure we could put these? This doesn't seem like our list to maintain.
To override the default role assignment, use the `WithRoleAssignments` API and assign built-in roles as shown in the following example: | ||
|
||
```csharp | ||
var builder = DistributedApplication.CreateBuilder(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your app needs to use a compute environment that supports role assignments. In 9.2 the only one we support is Azure Container Apps. So you need to call either:
- Aspire.Hosting.AzureContainerAppExtensions.AddAzureContainerAppEnvironment
- Aspire.Hosting.AzureContainerAppExtensions.AddAzureContainerAppsInfrastructure
In order for role assignments to work. If you don't enable ACA infrastructure, an exception is thrown when your app starts if you call .WithRoleAssignments
.
Summary
Add role assignments with .NET Aspire
Fixes #2788
Internal previews