Skip to content

resource-missing-read

Id
@azure-tools/typespec-azure-resource-manager/resource-missing-read

ARM resources with create or update operations must define a read operation.

An ARM resource with a create or update lifecycle operation must also provide a read operation. Clients need to retrieve the resource state after creating or updating it.

Define ArmResourceRead<Resource> alongside the resource’s create/update operations. A collection list does not replace a read of an individual resource. Delete-only resources are outside this rule’s scope.

  • Area: API

Without a read operation, clients cannot retrieve the state of a resource they can create or update. The rule reports one warning per resource, on the concrete interface declaring its registered create/update operation. Having both create and update operations does not produce two warnings. When writes are split across interfaces, the create operation’s interface takes priority over the update operation’s interface. A separate delete interface is not the diagnostic target.

For an existing Widget resource with WidgetProperties, this interface omits the read operation:

@armResourceOperations
interface Widgets {
createOrUpdate is ArmResourceCreateOrReplaceSync<Widget>;
update is ArmResourcePatchSync<Widget, WidgetProperties>;
}

Add a read using the standard ARM resource operation template:

@armResourceOperations
interface Widgets {
createOrUpdate is ArmResourceCreateOrReplaceSync<Widget>;
update is ArmResourcePatchSync<Widget, WidgetProperties>;
get is ArmResourceRead<Widget>;
}

These examples assume a model such as model Widget is TrackedResource<WidgetProperties> { ...ResourceNameParameter<Widget>; }, with a named properties model such as model WidgetProperties { label?: string; }.

Prefer adding the standard read operation. Suppress this rule only when an ARM reviewer approves a resource design that intentionally cannot be read; include the approval reason in the #suppress directive on the resource operation interface. Place suppression on the concrete create interface, or on the update interface when there is no create operation. Suppression on a separate delete interface does not suppress this warning.

This rule corresponds to AllResourcesMustHaveGetOperation. It checks registered native ARM lifecycle roles, not emitted response references. Legacy HTTP GET operations without ARM read metadata do not satisfy this check; registered reads with customized responses do. Full executable Swagger equivalence is not claimed. The discriminator-ancestor exemption is retained, but a clean supported polymorphic ARM fixture has not been established.