Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4f871a2
Initial plan for issue
Copilot May 25, 2025
b8f5001
Make existing private NameOutputReference properties public
Copilot May 25, 2025
8a7ee32
Add NameOutputReference to additional AzureProvisioningResource classes
Copilot May 25, 2025
3e475ba
Add name as a ProvisioningOutput in Azure resources with NameOutputRe…
Copilot May 25, 2025
7349481
Add unit tests for NameOutputReference properties
Copilot May 25, 2025
87dbb41
Update snapshots to include name output for ApplicationInsights and L…
Copilot May 25, 2025
ed42c0a
Update snapshot tests to include name output for AzureUserAssignedIde…
Copilot May 25, 2025
73ac86b
Update all snapshots to include name output for UserAssignedIdentity …
Copilot May 25, 2025
f0fdbaa
Add name output to remaining ApplicationInsights and LogAnalytics sna…
Copilot May 25, 2025
1438ad7
Fix spacing in bicep output for ApplicationInsights and LogAnalytics …
Copilot May 25, 2025
b3cde5b
Fix RoleAssignmentTests.SqlSupport snapshot file
Copilot May 25, 2025
252418c
Update output name to use existingResourceName in Application Insight…
davidfowl May 26, 2025
70f15e7
Remove obsolete tests for Azure resources and related functionality
davidfowl May 26, 2025
ec2e835
Remove ApplicationInsightsTests as they are no longer needed
davidfowl May 26, 2025
c490a30
Remove NameOutputReference from obsolete and duplicate properties
Copilot May 27, 2025
bc9983d
Restored NameOutputReference property on AzureUserAssignedIdentityRes…
Copilot May 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public class AzureAppConfigurationResource(string name, Action<AzureResourceInfr
/// </summary>
public BicepOutputReference Endpoint => new("appConfigEndpoint", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the connection string template for the manifest for the Azure App Configuration resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static IResourceBuilder<AzureApplicationInsightsResource> AddAzureApplica
});

infrastructure.Add(new ProvisioningOutput("appInsightsConnectionString", typeof(string)) { Value = appInsights.ConnectionString });

// Add name output for the resource to externalize role assignments
infrastructure.Add(new ProvisioningOutput("name", typeof(string)) { Value = appInsights.Name });
};

var resource = new AzureApplicationInsightsResource(name, configureInfrastructure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class AzureApplicationInsightsResource(string name, Action<AzureResourceI
: AzureProvisioningResource(name, configureInfrastructure),
IResourceWithConnectionString
{
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the "appInsightsConnectionString" output reference for the Azure Application Insights resource.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public class AzureOpenAIResource(string name, Action<AzureResourceInfrastructure
/// </summary>
public BicepOutputReference ConnectionString => new("connectionString", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the connection string template for the manifest for the resource.
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public class AzureCosmosDBResource(string name, Action<AzureResourceInfrastructu
/// </summary>
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets a value indicating whether the resource uses access key authentication.
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public class AzureEventHubsResource(string name, Action<AzureResourceInfrastruct
/// </summary>
public BicepOutputReference EventHubsEndpoint => new("eventHubsEndpoint", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

internal EndpointReference EmulatorEndpoint => new(this, "emulator");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public static IResourceBuilder<AzureLogAnalyticsWorkspaceResource> AddAzureLogAn
{
Value = workspace.Id
});

// Add name output for the resource to externalize role assignments
infrastructure.Add(new ProvisioningOutput("name", typeof(string))
{
Value = workspace.Name
});
};

var resource = new AzureLogAnalyticsWorkspaceResource(name, configureInfrastructure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace Aspire.Hosting.Azure;
public class AzureLogAnalyticsWorkspaceResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
: AzureProvisioningResource(name, configureInfrastructure)
{
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the "logAnalyticsWorkspaceId" output reference for the Azure Log Analytics Workspace resource.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public class AzurePostgresFlexibleServerResource(string name, Action<AzureResour
/// </summary>
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets a value indicating whether the resource uses password authentication.
Expand Down
5 changes: 5 additions & 0 deletions src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class AzurePostgresResource(PostgresServerResource innerResource, Action<
{
private readonly PostgresServerResource _innerResource = innerResource ?? throw new ArgumentNullException(nameof(innerResource));

/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this. The resource is obsolete. Plus nothing is not outputting the name in the bicep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the NameOutputReference property from AzurePostgresResource as it's obsolete and doesn't output the name in bicep. Fixed in commit c490a30.

Copy link
Member

Choose a reason for hiding this comment

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

Agree.


/// <summary>
/// Gets the "connectionString" secret output reference from the bicep template for the Azure Postgres Flexible Server.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.Redis/AzureRedisCacheResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class AzureRedisCacheResource(string name, Action<AzureResourceInfrastruc
/// </summary>
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets a value indicating whether the resource uses access key authentication.
Expand Down
5 changes: 5 additions & 0 deletions src/Aspire.Hosting.Azure.Redis/AzureRedisResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class AzureRedisResource(RedisResource innerResource, Action<AzureResourc
{
private readonly RedisResource _innerResource = innerResource ?? throw new ArgumentNullException(nameof(innerResource));

/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this. The resource is obsolete. Plus nothing is not outputting the name in the bicep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the NameOutputReference property from AzureRedisResource as it's obsolete and doesn't output the name in bicep. Fixed in commit c490a30.


/// <summary>
/// Gets the "connectionString" output reference from the bicep template for the Azure Redis resource.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class AzureSearchResource(string name, Action<AzureResourceInfrastructure
/// </remarks>
public BicepOutputReference ConnectionString => new("connectionString", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the connection string template for the manifest for the resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class AzureServiceBusResource(string name, Action<AzureResourceInfrastruc
/// </summary>
public BicepOutputReference ServiceBusEndpoint => new("serviceBusEndpoint", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

internal EndpointReference EmulatorEndpoint => new(this, "emulator");

Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class AzureSignalRResource(string name, Action<AzureResourceInfrastructur
/// </summary>
public BicepOutputReference HostName => new("hostName", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);
Copy link
Preview

Copilot AI May 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The NameOutputReference property is duplicated across many resource classes. Consider exposing it in the AzureProvisioningResource base class to avoid repetitive code.

Copilot uses AI. Check for mistakes.


/// <summary>
/// Gets the connection string template for the manifest for Azure SignalR.
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public AzureSqlServerResource(SqlServerServerResource innerResource, Action<Azur
/// </summary>
public BicepOutputReference FullyQualifiedDomainName => new("sqlServerFqdn", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

private BicepOutputReference AdminName => new("sqlServerAdminName", this);

Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public class AzureStorageResource(string name, Action<AzureResourceInfrastructur
/// </summary>
public BicepOutputReference TableEndpoint => new("tableEndpoint", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets a value indicating whether the Azure Storage resource is running in the local emulator.
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public class AzureWebPubSubResource(string name, Action<AzureResourceInfrastruct
/// </summary>
public BicepOutputReference Endpoint => new("endpoint", this);

private BicepOutputReference NameOutputReference => new("name", this);
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);

/// <summary>
/// Gets the connection string template for the manifest for Azure Web PubSub.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ namespace Aspire.Hosting.Azure;
public sealed class AzureUserAssignedIdentityResource(string name)
: AzureProvisioningResource(name, ConfigureAppIdentityInfrastructure), IAppIdentityResource
{
/// <summary>
/// Gets the "name" output reference for the resource.
/// </summary>
public BicepOutputReference NameOutputReference => new("name", this);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? We already have PrincipalName which is the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I've removed the NameOutputReference property since it duplicates the functionality of the existing PrincipalName property. Fixed in commit c490a30.

Copy link
Member

Choose a reason for hiding this comment

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

We should be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've restored the NameOutputReference property to AzureUserAssignedIdentityResource to maintain consistency across all Azure resources in commit bc9983d. This ensures the same pattern is followed for all the resources that inherit from AzureProvisioningResource.


/// <summary>
/// The identifier associated with the user assigned identity.
/// </summary>
Expand Down Expand Up @@ -55,6 +60,7 @@ private static void ConfigureAppIdentityInfrastructure(AzureResourceInfrastructu
infrastructure.Add(new ProvisioningOutput("clientId", typeof(string)) { Value = userAssignedIdentity.ClientId });
infrastructure.Add(new ProvisioningOutput("principalId", typeof(string)) { Value = userAssignedIdentity.PrincipalId });
infrastructure.Add(new ProvisioningOutput("principalName", typeof(string)) { Value = userAssignedIdentity.Name });
infrastructure.Add(new ProvisioningOutput("name", typeof(string)) { Value = userAssignedIdentity.Name });
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
}
}

output appInsightsConnectionString string = appInsights.properties.ConnectionString
output appInsightsConnectionString string = appInsights.properties.ConnectionString

output name string = appInsights.name
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
}
}

output appInsightsConnectionString string = appInsights.properties.ConnectionString
output appInsightsConnectionString string = appInsights.properties.ConnectionString

output name string = appInsights.name
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
}
}

output appInsightsConnectionString string = appInsights.properties.ConnectionString
output appInsightsConnectionString string = appInsights.properties.ConnectionString

output name string = appInsights.name
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09
}
}

output logAnalyticsWorkspaceId string = logAnalyticsWorkspace.id
output logAnalyticsWorkspaceId string = logAnalyticsWorkspace.id

output name string = logAnalyticsWorkspace.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
output principalName string = api_identity.name

output name string = api_identity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
output principalName string = api_identity.name

output name string = api_identity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
output principalName string = api_identity.name

output name string = api_identity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
output principalName string = api_identity.name

output name string = api_identity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = api_identity.properties.clientId

output principalId string = api_identity.properties.principalId

output principalName string = api_identity.name
output principalName string = api_identity.name

output name string = api_identity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ output clientId string = myidentity.properties.clientId

output principalId string = myidentity.properties.principalId

output principalName string = myidentity.name
output principalName string = myidentity.name

output name string = myidentity.name
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: existingResourceName
}

output appInsightsConnectionString string = appInsights.properties.ConnectionString
output appInsightsConnectionString string = appInsights.properties.ConnectionString

output name string = existingResourceName
Loading