Skip to content

use-scope-path-standard-name

Id
@azure-tools/typespec-azure-resource-manager/use-scope-path-standard-name

ARM scope paths must use the resourceGroupName and subscriptionId path parameters.

ARM scope paths must use the standard serialized path parameter names:

  • resourceGroupName after resourceGroups.
  • subscriptionId after subscriptions.

A custom base parameter with a different name, a literal scope value, or a missing scope parameter can produce a nonstandard resource scope.

This rule checks concrete GET, PUT, PATCH, and DELETE operations in ARM provider namespaces. Matching is case-insensitive. Each scope is checked only when its segment is present; the rule does not require adding either scope. POST and HEAD operations and generic template declarations are not checked. An operation with both names wrong receives two warnings under this one rule ID.

Use the standard ARM template base parameters. When customization is necessary, retain ResourceGroupParameter and CommonTypes.SubscriptionIdParameter rather than replacing them with differently named properties. The serialized @path name, not the TypeSpec property name, determines the path parameter name.

  • Area: API, SDK

Nonstandard scope parameters can produce inconsistent ARM routes and client parameter names.

The examples use a standard Widget ARM resource and its read operation.

The custom base replaces the standard parameters with subId and groupName.

model CustomBase {
...CommonTypes.ApiVersionParameter;
@path @segment("subscriptions") subId: string;
@path @segment("resourceGroups") groupName: string;
}
@armResourceOperations
interface Widgets {
read is ArmResourceRead<Widget, BaseParameters = CustomBase>;
}

Use the template’s default base parameters, which include both standard names.

@armResourceOperations
interface Widgets {
read is ArmResourceRead<Widget>;
}

For an intentional, reviewed path exception, place #suppress "@azure-tools/typespec-azure-resource-manager/use-scope-path-standard-name" "Reason for the exception." before the offending operation. The suppression applies to both naming checks.

The rule is enabled in the ARM library’s all ruleset and disabled in @azure-tools/typespec-azure-rulesets/resource-manager. Enable the rule explicitly when using that ruleset.

This rule combines PathContainsResourceGroup and PathContainsSubscriptionId. It preserves their case-insensitive full-path predicates: a canonical /resourceGroups/{resourceGroupName} or /subscriptions/{subscriptionId} occurrence satisfies that member even if another occurrence of the same segment differs. This is not a complete ARM path validator.

The native rule reports per concrete operation.