Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5bc26c7

Browse files
Skip role assignment handling for emulators (#9705) (#9716)
- 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>
1 parent26bef51 commit5bc26c7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎src/Aspire.Hosting.Azure/AzureResourcePreparer.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ private async Task BuildRoleAssignmentAnnotations(DistributedApplicationModel ap
143143
.ToLookup(a=>a.Target);
144144
foreach(varazureReferenceinazureReferences.OfType<AzureProvisioningResource>())
145145
{
146+
if(azureReference.IsContainer())
147+
{
148+
// Skip emulators
149+
continue;
150+
}
151+
146152
varroleAssignments=azureReferencesWithRoleAssignments[azureReference];
147153
if(roleAssignments.Any())
148154
{

‎tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,28 @@ await Verifier.Verify(storageRolesManifest.BicepText, extension: "bicep")
133133
}
134134
}
135135

136+
[Fact]
137+
publicasyncTaskDoesNotApplyRoleAssignmentsInRunModeForEmulators()
138+
{
139+
usingvarbuilder=TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
140+
builder.AddAzureContainerAppEnvironment("env");
141+
142+
builder.AddBicepTemplateString("foo","");
143+
144+
vardbsrv=builder.AddAzureSqlServer("dbsrv").RunAsContainer();
145+
vardb=dbsrv.AddDatabase("db");
146+
147+
varapi=builder.AddProject<Project>("api",launchProfileName:null)
148+
.WithReference(db);
149+
150+
usingvarapp=builder.Build();
151+
varmodel=app.Services.GetRequiredService<DistributedApplicationModel>();
152+
awaitExecuteBeforeStartHooksAsync(app,default);
153+
154+
// in RunMode, we skip applying the role assignments to a new 'dbsrv-roles' resource, since the storage is running as emulator.
155+
Assert.DoesNotContain(model.Resources.OfType<AzureProvisioningResource>(), r=>r.Name=="dbsrv-roles");
156+
}
157+
136158
[Fact]
137159
publicasyncTaskFindsAzureReferencesFromArguments()
138160
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp