Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Aspire.Hosting.Azure/AzureResourcePreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ private async Task BuildRoleAssignmentAnnotations(DistributedApplicationModel ap
.ToLookup(a => a.Target);
foreach (var azureReference in azureReferences.OfType<AzureProvisioningResource>())
{
if (azureReference.IsContainer())
{
// Skip emulators
continue;
}

var roleAssignments = azureReferencesWithRoleAssignments[azureReference];
if (roleAssignments.Any())
{
Expand Down
22 changes: 22 additions & 0 deletions tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@ await Verifier.Verify(storageRolesManifest.BicepText, extension: "bicep")
}
}

[Fact]
public async Task DoesNotApplyRoleAssignmentsInRunModeForEmulators()
{
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
builder.AddAzureContainerAppEnvironment("env");

builder.AddBicepTemplateString("foo", "");

var dbsrv = builder.AddAzureSqlServer("dbsrv").RunAsContainer();
var db = dbsrv.AddDatabase("db");

var api = builder.AddProject<Project>("api", launchProfileName: null)
.WithReference(db);

using var app = builder.Build();
var model = app.Services.GetRequiredService<DistributedApplicationModel>();
await ExecuteBeforeStartHooksAsync(app, default);

// in RunMode, we skip applying the role assignments to a new 'dbsrv-roles' resource, since the storage is running as emulator.
Assert.DoesNotContain(model.Resources.OfType<AzureProvisioningResource>(), r => r.Name == "dbsrv-roles");
}

[Fact]
public async Task FindsAzureReferencesFromArguments()
{
Expand Down