Skip to content

resource-envelope-schema

Id
@azure-tools/typespec-azure-resource-manager/resource-envelope-schema

Validate identity properties and tags in the ARM resource envelope.

The ARM resource envelope must contain read-only name, id, and type properties. If the envelope includes tags, its values must be strings.

  • Area: API, SDK

Missing or writable resource identity properties violate ARM guidelines. Non-string tag values do not conform to the Azure resource tags schema and can prevent SDK generation.

Assume Widget is an ARM resource. Its id and type properties must be read-only in the resource hierarchy:

model WidgetProperties {
displayName?: string;
}
model Widget is TrackedResource<WidgetProperties> {
@visibility(Lifecycle.Read, Lifecycle.Create)
id?: Azure.Core.armResourceIdentifier;
}
tags?: Record<int32>;

Resource identity properties are read-only

Section titled “Resource identity properties are read-only”

Use the standard ARM resource base types, which provide read-only name, id, and type properties:

model WidgetProperties {
displayName?: string;
}
model Widget is TrackedResource<WidgetProperties> {
...ResourceNameParameter<Widget>;
}

Use TrackedResource<WidgetProperties>, which provides the standard tags property. Do not redeclare tags on the resource model.

Fix the resource model to follow the ARM resource property and tags requirements. Exceptions should only be granted to match existing stable legacy API.

This rule combines RequiredPropertiesMissingInResourceModel and AzureResourceTagsSchema.