Azure / Azure/azure-sdk-for-net
docs(relationships): add concrete code examples to README
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 5.2k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 407
Description
## Summary
The newly introduced `Azure.ResourceManager.Relationships` package (1.0.0-beta.1, merged in #57520) had a generic boilerplate README with no service-specific code examples. Because `Microsoft.Relationships` introduces novel ARM concepts (`DependencyOf` and `ServiceGroupMember` relationship types), developers need concrete examples to understand how to use the library.
## Changes
### `sdk/relationships/Azure.ResourceManager.Relationships/README.md`
Replaced the generic "Code samples for using the management library for .NET can be found in the following locations" placeholder with four specific, snippet-backed examples covering the primary use cases:
1. **Create a `DependencyOf` relationship** — declares that one Azure resource depends on another
2. **Get a `DependencyOf` relationship** — retrieves an existing relationship
3. **Delete a `DependencyOf` relationship** — removes a dependency relationship
4. **Add a resource to a service group** — creates a `ServiceGroupMember` relationship
### `sdk/relationships/Azure.ResourceManager.Relationships/tests/Samples/RelationshipsSnippets.cs`
New handwritten snippet file containing compilable `[Test]` methods with `#region Snippet:...` / `#endregion` markers. These back the code blocks in the README so that `eng/scripts/Update-Snippets.ps1` can synchronize them and CI can validate they compile.
## Testing
The snippet file uses `[Ignore("Only verifying that the sample builds")]` consistent with the existing auto-generated sample files in the same directory. The code is validated at compile time.
> Generated by [Update Docs](https://github.com/Azure/azure-sdk-for-net/actions/runs/23959312644/agentic_workflow) · [◷](https://github.com/search?q=repo%3AAzure%2Fazure-sdk-for-net+%22gh-aw-workflow-id%3A+update-samples-and-docs%22&type=pullrequests)
---
> [!NOTE]
> This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
> The changes have been pushed to branch `docs/relationships-readme-examples-a016272957b5622f`.
>
> **[Click here to create the pull request](https://github.com/Azure/azure-sdk-for-net/compare/main...docs/relationships-readme-examples-a016272957b5622f?expand=1&title=docs(relationships)%3A%20add%20concrete%20code%20examples%20to%20README)**
To fix the permissions issue, go to **Settings** → **Actions** → **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ](https://github.github.com/gh-aw/reference/faq/#why-is-my-create-pull-request-workflow-failing-with-github-actions-is-not-permitted-to-create-or-approve-pull-requests)
Show patch preview (223 of 223 lines)
```diff
From 313df1f5cc78c47b21868958988f65d939504819 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 3 Apr 2026 19:40:00 +0000
Subject: [PATCH] docs(relationships): add concrete code examples to README
Add snippet-backed code examples to the Azure.ResourceManager.Relationships
README covering the key operations:
- Create a DependencyOf relationship (link two Azure resources)
- Get a DependencyOf relationship
- Delete a DependencyOf relationship
- Add a resource to a service group via ServiceGroupMember relationship
Added RelationshipsSnippets.cs test file with #region Snippet markers so
the examples are backed by compilable code and can be validated by CI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
.../README.md | 76 ++++++++++++-
.../tests/Samples/RelationshipsSnippets.cs | 104 ++++++++++++++++++
2 files changed, 178 insertions(+), 2 deletions(-)
create mode 100644 sdk/relationships/Azure.ResourceManager.Relationships/tests/Samples/RelationshipsSnippets.cs
diff --git a/sdk/relationships/Azure.ResourceManager.Relationships/README.md b/sdk/relationships/Azure.ResourceManager.Relationships/README.md
index 4915ea2b6..8737d001e 100644
--- a/sdk/relationships/Azure.ResourceManager.Relationships/README.md
+++ b/sdk/relationships/Azure.ResourceManager.Relationships/README.md
@@ -56,8 +56,80 @@ Documentation is available to help you learn how to use this package:
## Examples
-Code samples for using the management library for .NET can be found in the following locations
-- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples)
+### Create a DependencyOf relationship
+
+A `DependencyOf` relationship declares that one Azure resource depends on another, enabling dependency mapping and change-impact analysis.
+
+```C# Snippet:Relationships_CreateDependencyOf
+TokenCredential cred = new DefaultAzureCredential();
+ArmClien
... (truncated)
```
Contributor guide
Assessment
This issue has not been assessed yet.