Skip to content

Add Relationship Base Type - #4892

Open
alexchro93 wants to merge 10 commits into
mainfrom
chrostow/base-rel
Open

Add Relationship Base Type#4892
alexchro93 wants to merge 10 commits into
mainfrom
chrostow/base-rel

Conversation

@alexchro93

Copy link
Copy Markdown
Member

This PR introduces a base type for namespace Microsoft.Relationships. Relationships are extension resources used to establish a connection between a source ARM resource and target ARM resource.

Notably, two relationship types exist in a public preview state in ARM today: serviceGroupMember and dependencyOf.

The implementation of the Microsoft.Relationships base type is heavily inspired by the only other existing base type current: agent.

The relationship type is meant to be a lightweight ARM resources (meaning the resource payload has minimal properties and only really carries references to other ARM resources), however implementations of the relationship base type can new metadata about a relationship through extending the RelationshipMetadata model

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Copilot-Session: 8a6e07d6-3bd4-4373-b9a2-88ad69127fcf

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8a6e07d6-3bd4-4373-b9a2-88ad69127fcf
@microsoft-github-policy-service microsoft-github-policy-service Bot added int:azure-specs Run integration tests against azure-rest-api-specs lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library meta:website TypeSpec.io updates linter Issues related to linter rules labels Jul 14, 2026
* Applies the Relationship base type decorator automatically.
* @template Properties RP-specific properties for the relationship (must extend RelationshipProperties)
*/
@azureBaseType(#{ baseType: "Relationship", version: "2024-06-01" })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just thinking more about the baseType value and keeping a note for me. Assuming 'Relationship' also becomes the canonical base type, I would consider defining baseType as a constrained enum set having 'Relationship' & 'Agent'. Currently that is modeled as string which allows any string for the baseType. An open-ended string contract may introduce divergence across producers and consumers, making dependency tracking, and long-term schema governance significantly more challenging. I can do this once your PR gets merged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One question, is it possible for a resource to be an Agent and a Relationship?

The decorator allows this, but we should provide an example if this is a real scenario

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IMO, I do not think it is a real scenario. A single resource can't be an Agent (tracked type) and Relationship (extension type).

Comment thread packages/typespec-azure-resource-manager/lib/base-types/relationship.tsp Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bd00581e-a610-4edb-8426-dfc6dd89cedb
@alexchro93
alexchro93 marked this pull request as ready for review July 14, 2026 19:54
@azure-sdk-automation

azure-sdk-automation Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-azure-resource-manager
  • @azure-tools/typespec-azure-rulesets
Show changes

@azure-tools/typespec-azure-resource-manager - feature ✏️

Add the experimental Relationship base type for Azure Resource Manager extension resources, including flat relationship properties and lint validation for Relationship base type conformance.

@azure-tools/typespec-azure-rulesets - feature ✏️

Add the experimental Relationship base type for Azure Resource Manager extension resources, including flat relationship properties and lint validation for Relationship base type conformance.

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-azure-resource-manager@4892
npm i https://pkg.pr.new/@azure-tools/typespec-azure-rulesets@4892

commit: 7b6343d

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

@markcowl markcowl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also wonder if we want a resource type for this, especially if it is required to be an extension.

Comment thread packages/samples/specs/resource-manager/resource-types/relationship/main.tsp Outdated
Comment thread packages/samples/specs/resource-manager/resource-types/relationship/main.tsp Outdated
Comment thread packages/samples/specs/resource-manager/resource-types/relationship/main.tsp Outdated
Comment thread packages/typespec-azure-resource-manager/lib/base-types/relationship.tsp Outdated
* Applies the Relationship base type decorator automatically.
* @template Properties RP-specific properties for the relationship (must extend RelationshipProperties)
*/
@azureBaseType(#{ baseType: "Relationship", version: "2024-06-01" })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One question, is it possible for a resource to be an Agent and a Relationship?

The decorator allows this, but we should provide an example if this is a real scenario

}

const missing = [
"sourceId",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should either create templates for these types, or we should have a type that defines the required properties and a decorator that indicates what is required (property exists, optionality, etc.) and use this to drive the linting rule

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Essentially, if we have a `@baseTypeProperty decorator, which took a base type kind and version, we could have an internal-only type (or a set of them) that defined the required properties.

@alexchro93

Copy link
Copy Markdown
Member Author

I also wonder if we want a resource type for this, especially if it is required to be an extension.

@markcowl, can you please explain what you mean by this?

Comment thread packages/typespec-azure-resource-manager/lib/base-types/relationship.tsp Outdated
Comment thread packages/typespec-azure-resource-manager/lib/base-types/relationship.tsp Outdated
- "@azure-tools/typespec-azure-rulesets"
---

Add the experimental Relationship base type for Azure Resource Manager extension resources, including flat relationship properties and lint validation for Relationship base type conformance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add a short example of usage here - this will go into the release notes and the release blog post

sourceTenant: string;

/** The relationship target identifier. */
targetId: string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the Agent types, we split these into Appliance and UserDefined templates, with the appliance type having readOnly properties. If we are considering making some of these readOnly, it is easiest to make this part of the Appliance template

@@ -0,0 +1,41 @@
---
title: arm-relationship-base-type-required-properties

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To follow guidelines, we should rename this rule and type to use-relationship-required-properties

import { AzureBaseTypeInfo, getAzureBaseTypes } from "../base-types.js";
import { getArmResources } from "../resource.js";

export const armRelationshipBaseTypeRequiredPropertiesRule = createRule({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

will need to change this name as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

int:azure-specs Run integration tests against azure-rest-api-specs lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library linter Issues related to linter rules meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants