eng/packages/http-client-csharp-mgmt/docs/resolve-arm-resources-integration.md
This document describes the integration of the resolveArmResources API from @azure-tools/typespec-azure-resource-manager into our codebase.
The resolveArmResources API is a standardized way provided by the TypeSpec ARM library to extract and resolve ARM resource information from TypeSpec definitions. It provides:
We want to migrate from our custom resource detection logic in resource-detection.ts to use the standardized resolveArmResources API. This will:
The migration is being done incrementally:
resolve-arm-resources-converter.ts that wraps resolveArmResources and converts Provider format to our ArmProviderSchema formatresource-detection.test.ts and non-resource-methods.test.tsuse-legacy-resource-detection as a feature flag to control resource detection behaviorbuildArmProviderSchema calls the converter to use resolveArmResources instead of custom logictspconfig.yaml)How to opt-in to the new resolveArmResources API:
Add the following to your tspconfig.yaml or emitter options:
emit:
- "@azure-typespec/http-client-csharp-mgmt"
options:
"@azure-typespec/http-client-csharp-mgmt":
use-legacy-resource-detection: false
use-legacy-resource-detection: false flag in our internal test projectsuse-legacy-resource-detection: false flag in a selected set of real RPsfalse (making resolveArmResources the default)resolveArmResourcesProvider format to our ArmProviderSchema formatProvider format if beneficialinterface Provider {
resources?: ResolvedResource[];
providerOperations?: ArmResourceOperation[];
}
interface ResolvedResource {
type: Model;
kind: "Tracked" | "Proxy" | "Extension" | "Other";
providerNamespace: string;
operations: ArmResolvedOperationsForResource;
associatedOperations?: ArmResourceOperation[];
resourceName: string;
resourceType: ResourceType;
resourceInstancePath: string;
parent?: ResolvedResource;
scope?: string | ResolvedResource;
}
interface ArmProviderSchema {
resources: ArmResourceSchema[];
nonResourceMethods: NonResourceMethod[];
}
interface ArmResourceSchema {
resourceModelId: string;
metadata: ResourceMetadata;
}
interface ResourceMetadata {
resourceIdPattern: string;
resourceType: string;
methods: ResourceMethod[];
resourceScope: ResourceScope;
parentResourceId?: string;
parentResourceModelId?: string;
singletonResourceName?: string;
resourceName: string;
}
use-legacy-resource-detection: false flag in internal test projects to validate generationfalse (making resolveArmResources the default behavior)resolveArmResourcesProvider format if beneficial