Skip to content

Commit c8b9a0c

Browse files
Copilotdavidfowleerhardt
authored
Expose the NameOutputReference property on AzureResources (#9501)
* Initial plan for issue * Make existing private NameOutputReference properties public Co-authored-by: davidfowl <[email protected]> * Add NameOutputReference to additional AzureProvisioningResource classes Co-authored-by: davidfowl <[email protected]> * Add name as a ProvisioningOutput in Azure resources with NameOutputReference Co-authored-by: davidfowl <[email protected]> * Add unit tests for NameOutputReference properties Co-authored-by: davidfowl <[email protected]> * Update snapshots to include name output for ApplicationInsights and LogAnalytics resources Co-authored-by: davidfowl <[email protected]> * Update snapshot tests to include name output for AzureUserAssignedIdentity resources Co-authored-by: davidfowl <[email protected]> * Update all snapshots to include name output for UserAssignedIdentity resources Co-authored-by: davidfowl <[email protected]> * Add name output to remaining ApplicationInsights and LogAnalytics snapshots Co-authored-by: davidfowl <[email protected]> * Fix spacing in bicep output for ApplicationInsights and LogAnalytics snapshots Co-authored-by: davidfowl <[email protected]> * Fix RoleAssignmentTests.SqlSupport snapshot file Co-authored-by: davidfowl <[email protected]> * Update output name to use existingResourceName in Application Insights and Log Analytics snapshots * Remove obsolete tests for Azure resources and related functionality * Remove ApplicationInsightsTests as they are no longer needed * Remove NameOutputReference from obsolete and duplicate properties Co-authored-by: eerhardt <[email protected]> * Restored NameOutputReference property on AzureUserAssignedIdentityResource for consistency Co-authored-by: davidfowl <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: davidfowl <[email protected]> Co-authored-by: David Fowler <[email protected]> Co-authored-by: eerhardt <[email protected]>
1 parent 8cf393d commit c8b9a0c

File tree

34 files changed

+124
-29
lines changed

34 files changed

+124
-29
lines changed

src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public class AzureAppConfigurationResource(string name, Action<AzureResourceInfr
2121
/// </summary>
2222
public BicepOutputReference Endpoint => new("appConfigEndpoint", this);
2323

24-
private BicepOutputReference NameOutputReference => new("name", this);
24+
/// <summary>
25+
/// Gets the "name" output reference for the resource.
26+
/// </summary>
27+
public BicepOutputReference NameOutputReference => new("name", this);
2528

2629
/// <summary>
2730
/// Gets the connection string template for the manifest for the Azure App Configuration resource.

src/Aspire.Hosting.Azure.ApplicationInsights/AzureApplicationInsightsExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public static IResourceBuilder<AzureApplicationInsightsResource> AddAzureApplica
106106
});
107107

108108
infrastructure.Add(new ProvisioningOutput("appInsightsConnectionString", typeof(string)) { Value = appInsights.ConnectionString });
109+
110+
// Add name output for the resource to externalize role assignments
111+
infrastructure.Add(new ProvisioningOutput("name", typeof(string)) { Value = appInsights.Name });
109112
};
110113

111114
var resource = new AzureApplicationInsightsResource(name, configureInfrastructure);

src/Aspire.Hosting.Azure.ApplicationInsights/AzureApplicationInsightsResource.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class AzureApplicationInsightsResource(string name, Action<AzureResourceI
1414
: AzureProvisioningResource(name, configureInfrastructure),
1515
IResourceWithConnectionString
1616
{
17+
/// <summary>
18+
/// Gets the "name" output reference for the resource.
19+
/// </summary>
20+
public BicepOutputReference NameOutputReference => new("name", this);
21+
1722
/// <summary>
1823
/// Gets the "appInsightsConnectionString" output reference for the Azure Application Insights resource.
1924
/// </summary>

src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public class AzureOpenAIResource(string name, Action<AzureResourceInfrastructure
2424
/// </summary>
2525
public BicepOutputReference ConnectionString => new("connectionString", this);
2626

27-
private BicepOutputReference NameOutputReference => new("name", this);
27+
/// <summary>
28+
/// Gets the "name" output reference for the resource.
29+
/// </summary>
30+
public BicepOutputReference NameOutputReference => new("name", this);
2831

2932
/// <summary>
3033
/// Gets the connection string template for the manifest for the resource.

src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public class AzureCosmosDBResource(string name, Action<AzureResourceInfrastructu
4343
/// </summary>
4444
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
4545

46-
private BicepOutputReference NameOutputReference => new("name", this);
46+
/// <summary>
47+
/// Gets the "name" output reference for the resource.
48+
/// </summary>
49+
public BicepOutputReference NameOutputReference => new("name", this);
4750

4851
/// <summary>
4952
/// Gets a value indicating whether the resource uses access key authentication.

src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public class AzureEventHubsResource(string name, Action<AzureResourceInfrastruct
3333
/// </summary>
3434
public BicepOutputReference EventHubsEndpoint => new("eventHubsEndpoint", this);
3535

36-
private BicepOutputReference NameOutputReference => new("name", this);
36+
/// <summary>
37+
/// Gets the "name" output reference for the resource.
38+
/// </summary>
39+
public BicepOutputReference NameOutputReference => new("name", this);
3740

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

src/Aspire.Hosting.Azure.OperationalInsights/AzureLogAnalyticsWorkspaceExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public static IResourceBuilder<AzureLogAnalyticsWorkspaceResource> AddAzureLogAn
4848
{
4949
Value = workspace.Id
5050
});
51+
52+
// Add name output for the resource to externalize role assignments
53+
infrastructure.Add(new ProvisioningOutput("name", typeof(string))
54+
{
55+
Value = workspace.Name
56+
});
5157
};
5258

5359
var resource = new AzureLogAnalyticsWorkspaceResource(name, configureInfrastructure);

src/Aspire.Hosting.Azure.OperationalInsights/AzureLogAnalyticsWorkspaceResource.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ namespace Aspire.Hosting.Azure;
1111
public class AzureLogAnalyticsWorkspaceResource(string name, Action<AzureResourceInfrastructure> configureInfrastructure)
1212
: AzureProvisioningResource(name, configureInfrastructure)
1313
{
14+
/// <summary>
15+
/// Gets the "name" output reference for the resource.
16+
/// </summary>
17+
public BicepOutputReference NameOutputReference => new("name", this);
18+
1419
/// <summary>
1520
/// Gets the "logAnalyticsWorkspaceId" output reference for the Azure Log Analytics Workspace resource.
1621
/// </summary>

src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public class AzurePostgresFlexibleServerResource(string name, Action<AzureResour
3535
/// </summary>
3636
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
3737

38-
private BicepOutputReference NameOutputReference => new("name", this);
38+
/// <summary>
39+
/// Gets the "name" output reference for the resource.
40+
/// </summary>
41+
public BicepOutputReference NameOutputReference => new("name", this);
3942

4043
/// <summary>
4144
/// Gets a value indicating whether the resource uses password authentication.

src/Aspire.Hosting.Azure.Redis/AzureRedisCacheResource.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public class AzureRedisCacheResource(string name, Action<AzureResourceInfrastruc
3131
/// </summary>
3232
internal IAzureKeyVaultSecretReference? ConnectionStringSecretOutput { get; set; }
3333

34-
private BicepOutputReference NameOutputReference => new("name", this);
34+
/// <summary>
35+
/// Gets the "name" output reference for the resource.
36+
/// </summary>
37+
public BicepOutputReference NameOutputReference => new("name", this);
3538

3639
/// <summary>
3740
/// Gets a value indicating whether the resource uses access key authentication.

0 commit comments

Comments
 (0)