From 9719d7cab4d3a01e6563651801ac89766ad6d663 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:37:24 +0800 Subject: [PATCH 1/7] Add resource relationship docs --- docs/fundamentals/app-host-overview.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index c8e517184f..2b5c7bd7a3 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -488,6 +488,32 @@ This logic can easily be inverted to connect to an existing Redis resource when > [!IMPORTANT] > .NET Aspire provides common APIs to control the modality of resource builders, allowing resources to behave differently based on the execution mode. The fluent APIs are prefixed with `RunAs*` and `PublishAs*`. The `RunAs*` APIs influence the local development (or run mode) behavior, whereas the `PublishAs*` APIs influence the publishing of the resource. +## Resource relationships + +Resource relationships link resources together and they are displayed in the dashboard. Relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships are used to control resource nesting on the resources page. + +Relationship have a descriptive type and they're automatically created by some app model APIs. For example: + +* adds a relationship to the target resource with the type `Reference`. +* adds a relationship to the target resource with the type `WaitFor`. +* Adding a database to a DB container adds a relationship from the database to the container with the type `Parent` + +Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`: + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +var catalogDb = builder.AddPostgres("postgres") + .WithDataVolume() + .AddDatabase("catalogdb"); + +builder.AddProject("migration") + .WithReference(catalogDb) + .WithParentRelationship(catalogDb); + +builder.Build().Run(); +``` + ## See also - [.NET Aspire integrations overview](integrations-overview.md) From 1eb77b9737bd35b0d77f9300bbe2b9f17f552041 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:40:22 +0800 Subject: [PATCH 2/7] Fix linter --- docs/fundamentals/app-host-overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 2b5c7bd7a3..92fa502a4c 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -494,9 +494,9 @@ Resource relationships link resources together and they are displayed in the das Relationship have a descriptive type and they're automatically created by some app model APIs. For example: -* adds a relationship to the target resource with the type `Reference`. -* adds a relationship to the target resource with the type `WaitFor`. -* Adding a database to a DB container adds a relationship from the database to the container with the type `Parent` +- adds a relationship to the target resource with the type `Reference`. +- adds a relationship to the target resource with the type `WaitFor`. +- Adding a database to a DB container adds a relationship from the database to the container with the type `Parent` Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`: From 93fbba3c51cefe259527dee8d65998f63873e99d Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:49:23 +0800 Subject: [PATCH 3/7] Update --- docs/fundamentals/app-host-overview.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 92fa502a4c..6206287c65 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -488,17 +488,17 @@ This logic can easily be inverted to connect to an existing Redis resource when > [!IMPORTANT] > .NET Aspire provides common APIs to control the modality of resource builders, allowing resources to behave differently based on the execution mode. The fluent APIs are prefixed with `RunAs*` and `PublishAs*`. The `RunAs*` APIs influence the local development (or run mode) behavior, whereas the `PublishAs*` APIs influence the publishing of the resource. -## Resource relationships +## Resource Relationships -Resource relationships link resources together and they are displayed in the dashboard. Relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships are used to control resource nesting on the resources page. +Resource relationships link resources together and are displayed in the dashboard. These relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. -Relationship have a descriptive type and they're automatically created by some app model APIs. For example: +Each relationship has a descriptive type and is automatically created by some app model APIs. For example: -- adds a relationship to the target resource with the type `Reference`. -- adds a relationship to the target resource with the type `WaitFor`. -- Adding a database to a DB container adds a relationship from the database to the container with the type `Parent` +- adds a relationship to the target resource with the type `Reference`. +- adds a relationship to the target resource with the type `WaitFor`. +- Adding a database to a DB container creates a relationship from the database to the container with the type `Parent`. -Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`: +Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`. ```csharp var builder = DistributedApplication.CreateBuilder(args); @@ -514,6 +514,11 @@ builder.AddProject("migration") builder.Build().Run(); ``` +The preceding example configures the `migration` project to have the `catalogdb` database resource as its parent. The `Parent` relationship is special because it controls resource nesting on the resource page. In this example, `migration` is nested under `catalogdb`. + +> [!NOTE] +> There is validation for parent relationships to prevent a resource from having multiple parents or creating a circular reference. These configurations can't be rendered in the UI, and the app model will throw an error. + ## See also - [.NET Aspire integrations overview](integrations-overview.md) From c17a501a7b0cf7c8019a5727a18ab981b3f199c7 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:50:49 +0800 Subject: [PATCH 4/7] Update --- docs/fundamentals/app-host-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 6206287c65..972735fda9 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -514,7 +514,7 @@ builder.AddProject("migration") builder.Build().Run(); ``` -The preceding example configures the `migration` project to have the `catalogdb` database resource as its parent. The `Parent` relationship is special because it controls resource nesting on the resource page. In this example, `migration` is nested under `catalogdb`. +The preceding example uses `WithParentRelationship` to configure `catalogdb` database as the `migration` project's parent. The `Parent` relationship is special because it controls resource nesting on the resource page. In this example, `migration` is nested under `catalogdb`. > [!NOTE] > There is validation for parent relationships to prevent a resource from having multiple parents or creating a circular reference. These configurations can't be rendered in the UI, and the app model will throw an error. From fc4d1b81565c08d843e584ba78eee3a02a91bbb4 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:58:58 +0800 Subject: [PATCH 5/7] Update --- docs/fundamentals/app-host-overview.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 972735fda9..e8bcd83f29 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -490,15 +490,15 @@ This logic can easily be inverted to connect to an existing Redis resource when ## Resource Relationships -Resource relationships link resources together and are displayed in the dashboard. These relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. +Resource relationships link resources together. Relationships are informational and don’t impact an app’s runtime behavior. Instead, they’re used when displaying details about resources in the dashboard. For example, relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. -Each relationship has a descriptive type and is automatically created by some app model APIs. For example: +Relationships are automatically created by some app model APIs. For example: -- adds a relationship to the target resource with the type `Reference`. -- adds a relationship to the target resource with the type `WaitFor`. -- Adding a database to a DB container creates a relationship from the database to the container with the type `Parent`. +- adds a relationship to the target resource with the type `Reference`. +- adds a relationship to the target resource with the type `WaitFor`. +- Adding a database to a DB container creates a relationship from the database to the container with the type `Parent`. -Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`. +Relationships can also be explicitly added to the app model using `WithRelationship` and `WithParentRelationship`. ```csharp var builder = DistributedApplication.CreateBuilder(args); From 2f218554f59ff4243ff52a0f5ffcd24d822e66ae Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 19 Feb 2025 11:59:29 +0800 Subject: [PATCH 6/7] Update --- docs/fundamentals/app-host-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index e8bcd83f29..d30c7457e6 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -490,7 +490,7 @@ This logic can easily be inverted to connect to an existing Redis resource when ## Resource Relationships -Resource relationships link resources together. Relationships are informational and don’t impact an app’s runtime behavior. Instead, they’re used when displaying details about resources in the dashboard. For example, relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. +Resource relationships link resources together. Relationships are informational and don't impact an app's runtime behavior. Instead, they're used when displaying details about resources in the dashboard. For example, relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. Relationships are automatically created by some app model APIs. For example: From 29a3b4a52089d5efc761f25b83d7e836d1ec87f6 Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 19 Feb 2025 09:35:07 -0600 Subject: [PATCH 7/7] Apply suggestions from code review --- docs/fundamentals/app-host-overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index d30c7457e6..1fc5ceee99 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -488,7 +488,7 @@ This logic can easily be inverted to connect to an existing Redis resource when > [!IMPORTANT] > .NET Aspire provides common APIs to control the modality of resource builders, allowing resources to behave differently based on the execution mode. The fluent APIs are prefixed with `RunAs*` and `PublishAs*`. The `RunAs*` APIs influence the local development (or run mode) behavior, whereas the `PublishAs*` APIs influence the publishing of the resource. -## Resource Relationships +## Resource relationships Resource relationships link resources together. Relationships are informational and don't impact an app's runtime behavior. Instead, they're used when displaying details about resources in the dashboard. For example, relationships are visible in the [dashboard's resource details](./dashboard/explore.md#resource-details), and `Parent` relationships control resource nesting on the resources page. @@ -517,7 +517,7 @@ builder.Build().Run(); The preceding example uses `WithParentRelationship` to configure `catalogdb` database as the `migration` project's parent. The `Parent` relationship is special because it controls resource nesting on the resource page. In this example, `migration` is nested under `catalogdb`. > [!NOTE] -> There is validation for parent relationships to prevent a resource from having multiple parents or creating a circular reference. These configurations can't be rendered in the UI, and the app model will throw an error. +> There's validation for parent relationships to prevent a resource from having multiple parents or creating a circular reference. These configurations can't be rendered in the UI, and the app model will throw an error. ## See also