Skip to content

Skip role assignment handling for emulators #9705

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

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

davidfowl
Copy link
Member

Description

  • Updated BuildRoleAssignmentAnnotations to skip processing for container emulators.
  • Added a new test DoesNotApplyRoleAssignmentsInRunModeForEmulators to verify that role assignments are not applied to emulator resources.

Fixes #9422

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

- Updated `BuildRoleAssignmentAnnotations` to skip processing for container emulators.
- Added a new test `DoesNotApplyRoleAssignmentsInRunModeForEmulators` to verify that role assignments are not applied to emulator resources.
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 05:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the role assignment handling logic to skip processing for container emulator resources and adds a corresponding unit test to verify this behavior.

  • Skips role assignment processing for emulator resources in AzureResourcePreparer.
  • Adds a dedicated test to ensure that role assignments are not applied for emulator resources in run mode.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs Added test DoesNotApplyRoleAssignmentsInRunModeForEmulators verifying skip behavior for emulator resources.
src/Aspire.Hosting.Azure/AzureResourcePreparer.cs Updated BuildRoleAssignmentAnnotations to bypass processing for resources identified as containers.
Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:151

  • [nitpick] Consider renaming the method 'IsContainer()' to a more explicit name (e.g., 'IsContainerEmulator()') to clarify that it checks for emulator resources, thereby improving code readability.
if (azureReference.IsContainer())

@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Jun 5, 2025
@davidfowl
Copy link
Member Author

/backport to release/9.3

Copy link
Contributor

github-actions bot commented Jun 5, 2025

Started backporting to release/9.3: https://github.com/dotnet/aspire/actions/runs/15469706213

Copy link
Contributor

github-actions bot commented Jun 5, 2025

@davidfowl backporting to "release/9.3" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Skip role assignment handling for emulators
Using index info to reconstruct a base tree...
M	src/Aspire.Hosting.Azure/AzureResourcePreparer.cs
M	tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs
Falling back to patching base and 3-way merge...
Auto-merging tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs
Auto-merging src/Aspire.Hosting.Azure/AzureResourcePreparer.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Skip role assignment handling for emulators
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@davidfowl davidfowl merged commit a1ab4f1 into main Jun 5, 2025
256 checks passed
@davidfowl davidfowl deleted the davidfowl/skip-roles-for-emulators branch June 5, 2025 20:51
@davidfowl
Copy link
Member Author

@eerhardt can you backport this change to 9.3?

@eerhardt
Copy link
Member

eerhardt commented Jun 5, 2025

@eerhardt can you backport this change to 9.3?

Yes. Will do.

eerhardt pushed a commit to eerhardt/aspire that referenced this pull request Jun 5, 2025
- Updated `BuildRoleAssignmentAnnotations` to skip processing for container emulators.
- Added a new test `DoesNotApplyRoleAssignmentsInRunModeForEmulators` to verify that role assignments are not applied to emulator resources.
danmoseley pushed a commit that referenced this pull request Jun 6, 2025
- Updated `BuildRoleAssignmentAnnotations` to skip processing for container emulators.
- Added a new test `DoesNotApplyRoleAssignmentsInRunModeForEmulators` to verify that role assignments are not applied to emulator resources.

Co-authored-by: David Fowler <davidfowl@gmail.com>
@danmoseley
Copy link
Member

Patched in 9.3.1. To pick up this fix if you need it,

For existing projects targeting 9.3.0, please update as follows;
<Sdk Name="Aspire.AppHost.Sdk" Version="9.3.0" /> to <Sdk Name="Aspire.AppHost.Sdk" Version="9.3.1" /> and
<PackageReference Include="Aspire...." Version="9.3.0" /> to <PackageReference Include="Aspire...." Version="9.3.1" /> and restore packages.

If you're creating new projects, you can just install and use the updated project templates: dotnet new install Aspire.ProjectTemplates::9.3.1 --force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AddAzureSqlServer with RunAsContainer tries to provision roles when running locally
3 participants