Decorators
Azure.Core
Section titled “Azure.Core”@azureServiceConfigurations
Section titled “@azureServiceConfigurations”Pairs named HTTP server endpoints with OAuth authentication configurations.
Requires a public configuration, which is always the default regardless of declaration order. Calls @server for each configuration, with public first, and exposes the combined OR of HTTP authentication requirements. Existing AND groups and credential alternatives are preserved.
The HTTP view exposes servers and auth alternatives independently. Azure Core metadata retains their pairing and the public default for SDK generation.
Every configuration must include OAuth2, but OAuth flows, URLs, scopes, and authentication requirements may differ between configurations. Use ordinary HTTP authentication models. Do not combine this decorator with @server or @useAuth on the same namespace.
OAuth URL metadata does not change a caller-owned credential’s authority or tenant.
Declare a value record and use typeref(...) to reference authentication types and endpoint parameter models. Enable the experimental typeref compiler feature in the consuming project’s tspconfig.yaml:
kind: projectfeatures: - typeref@Azure.Core.azureServiceConfigurations(configurations: valueof Record<Azure.Core.AzureServiceConfiguration>)Target
Section titled “Target”The namespace using these configurations.
Namespace
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| configurations | valueof Record<Azure.Core.AzureServiceConfiguration> | The named endpoint and authentication records. |
Examples
Section titled “Examples”model PublicAuth is AadOauth2Auth< ["https://api.loganalytics.io/.default"], "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", "https://login.microsoftonline.com/common/oauth2/v2.0/token">;model GovernmentAuth is AadOauth2Auth< ["https://api.loganalytics.us/.default"], "https://login.microsoftonline.us/common/oauth2/v2.0/authorize", "https://login.microsoftonline.us/common/oauth2/v2.0/token">;
const Configurations: Record<AzureServiceConfiguration> = #{ public: #{ endpoint: "https://api.loganalytics.io", authentication: typeref(PublicAuth) }, government: #{ endpoint: "https://api.loganalytics.us", authentication: typeref(GovernmentAuth) },};
@service@azureServiceConfigurations(Configurations)namespace Logs { @get op query(): string;}Parameterized endpoint
Section titled “Parameterized endpoint”Declare endpoint parameters inline with parameters: typeref({ ... }), using the same property types and defaults as @server. Here, account is required and region defaults to "westus".
import "@typespec/http";import "@azure-tools/typespec-azure-core";
using TypeSpec.Http;using Azure.Core;
model ServiceAuth is AadOauth2Auth<["https://example.com/.default"]>;
const Configurations: Record<AzureServiceConfiguration> = #{ public: #{ endpoint: "https://{account}.{region}.example.com", authentication: typeref(ServiceAuth), parameters: typeref({ @doc("Account name.") account: string,
@doc("Deployment region.") region?: string = "westus", }), description: "Regional service endpoint", },};
@service@azureServiceConfigurations(Configurations)namespace RegionalService { @get op read(): string;}@finalLocation
Section titled “@finalLocation”Identifies a ModelProperty as containing the final location for the operation result.
@Azure.Core.finalLocation(finalResult?: Model | unknown | void)Target
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| finalResult | Model | unknown | void | Sets the expected return value for the final result. Overrides any value provided in the decorated property, if the property uses ResourceLocation |
@finalOperation
Section titled “@finalOperation”Identifies that an operation is the final operation for an LRO.
@Azure.Core.finalOperation(linkedOperation: Operation, parameters?: {})Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| linkedOperation | Operation | The linked Operation |
| parameters | {} | Map of RequestParameter<Name> and/or ResponseProperty<Name> that willbe passed to the linked operation request. |
@lroCanceled
Section titled “@lroCanceled”Used for custom StatusMonitor implementation. Identifies an EnumMember as a long-running “Canceled” terminal state.
@Azure.Core.lroCanceledTarget
Section titled “Target”EnumMember | UnionVariant
Parameters
Section titled “Parameters”None
@lroErrorResult
Section titled “@lroErrorResult”Used for custom StatusMonitor implementation. Identifies a model property of a StatusMonitor as containing the result of a long-running operation that terminates unsuccessfully (Failed).
@Azure.Core.lroErrorResultTarget
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”None
@lroFailed
Section titled “@lroFailed”Used for custom StatusMonitor implementation. Identifies an enum member as a long-running “Failed” terminal state.
@Azure.Core.lroFailedTarget
Section titled “Target”EnumMember | UnionVariant
Parameters
Section titled “Parameters”None
@lroResult
Section titled “@lroResult”Used for custom StatusMonitor implementation. Identifies a model property of a StatusMonitor as containing the result of a long-running operation that terminates successfully (Succeeded).
@Azure.Core.lroResultTarget
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”None
@lroStatus
Section titled “@lroStatus”Used for custom StatusMonitor implementation. Identifies an Enum or ModelProperty as containing long-running operation status.
@Azure.Core.lroStatusTarget
Section titled “Target”Enum | Union | ModelProperty
Parameters
Section titled “Parameters”None
@lroSucceeded
Section titled “@lroSucceeded”Used for custom StatusMonitor implementation. Identifies an EnumMember as a long-running “Succeeded” terminal state.
@Azure.Core.lroSucceededTarget
Section titled “Target”EnumMember | UnionVariant
Parameters
Section titled “Parameters”None
@operationLink
Section titled “@operationLink”Identifies an operation that is linked to the target operation.
@Azure.Core.operationLink(linkedOperation: Operation, linkType: valueof string, parameters?: {})Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| linkedOperation | Operation | The linked Operation |
| linkType | valueof string | A string indicating the role of the linked operation |
| parameters | {} | Map of RequestParameter<Name> and/or ResponseProperty<Name> that willbe passed to the linked operation request. |
@pollingLocation
Section titled “@pollingLocation”Identifies a model property as containing the location to poll for operation state.
@Azure.Core.pollingLocation(options?: Azure.Core.PollingOptions)Target
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| options | PollingOptions | PollingOptions for the poller pointed to by this link. Overrides settings derived from property value it is decorating, if the value of the property is ResourceLocation |
@pollingOperation
Section titled “@pollingOperation”Identifies that an operation is a polling operation for an LRO.
@Azure.Core.pollingOperation(linkedOperation: Operation, parameters?: {})Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| linkedOperation | Operation | The linked Operation |
| parameters | {} | Map of RequestParameter<Name> and/or ResponseProperty<Name> that willbe passed to the linked operation request. |
@pollingOperationParameter
Section titled “@pollingOperationParameter”Used to define how to call custom polling operations for long-running operations.
@Azure.Core.pollingOperationParameter(targetParameter?: ModelProperty | string)Target
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| targetParameter | ModelProperty | string | A reference to the polling operation parameter this parameter provides a value for, or the name of that parameter. The default value is the name of the decorated parameter or property. |
@previewVersion
Section titled “@previewVersion”Decorator that marks a Version EnumMember as a preview version. This is used to indicate that the version is not yet stable and may change in future releases.
@Azure.Core.previewVersionTarget
Section titled “Target”The EnumMember that represents the preview version.
EnumMember
Parameters
Section titled “Parameters”None
Examples
Section titled “Examples”@versioned(Versions)@service(#{ title: "Widget Service" })namespace DemoService;
enum Versions { v1, v2,
@previewVersion v3Preview,}@uniqueItems
Section titled “@uniqueItems”Specifies that an array model or array-typed property should contain only unique items.
@Azure.Core.uniqueItemsTarget
Section titled “Target”ModelProperty | Model
Parameters
Section titled “Parameters”None
@useFinalStateVia
Section titled “@useFinalStateVia”Overrides the final state value for an operation
@Azure.Core.useFinalStateVia(finalState: valueof "original-uri" | "operation-location" | "location" | "azure-async-operation")Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| finalState | valueof "original-uri" | "operation-location" | "location" | "azure-async-operation" | The desired final state value |
Azure.Core.Foundations
Section titled “Azure.Core.Foundations”@omitKeyProperties
Section titled “@omitKeyProperties”Deletes any key properties from the model.
@Azure.Core.Foundations.omitKeyPropertiesTarget
Section titled “Target”Model
Parameters
Section titled “Parameters”None
@requestParameter
Section titled “@requestParameter”Identifies a property on a request model that serves as a linked operation parameter.
@Azure.Core.Foundations.requestParameter(name: valueof string)Target
Section titled “Target”Model
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| name | valueof string | Property name on the target |
@responseProperty
Section titled “@responseProperty”Identifies a property on all non-error response models that serve as a linked operation parameter.
@Azure.Core.Foundations.responseProperty(name: valueof string)Target
Section titled “Target”Model
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| name | valueof string | Property name on the target |
Azure.Core.Legacy
Section titled “Azure.Core.Legacy”@overrideApiVersion
Section titled “@overrideApiVersion”Overrides the API-version wire value used for operations within a namespace or interface.
The value is opaque and does not need to be declared by the service version enum. The override is inherited by enclosed namespaces, interfaces, and operations, with the nearest override taking precedence.
This decorator is considered legacy functionality and should only be used to preserve compatibility with an existing SDK.
@Azure.Core.Legacy.overrideApiVersion(version: valueof string)Target
Section titled “Target”The namespace or interface whose operations use the API-version override.
Namespace | Interface
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| version | valueof string | The non-empty API-version wire value. |
Examples
Section titled “Examples”Override an interface API version
Section titled “Override an interface API version”@Azure.Core.Legacy.overrideApiVersion("2021-11-01")interface Widgets { get(): void;}Azure.Core.Traits
Section titled “Azure.Core.Traits”@trait
Section titled “@trait”@trait marks a model type as representing a ‘trait’ and performs basic validation
checks.
@Azure.Core.Traits.trait(traitName?: valueof string)Target
Section titled “Target”The model type to mark as a trait.
Model
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| traitName | valueof string | An optional name to uniquely identify the trait. If unspecified, the model type name is used. |
@traitAdded
Section titled “@traitAdded”Sets the version for when the trait was added to the specification. Can be applied to either a trait model type or its envelope property.
@Azure.Core.Traits.traitAdded(addedVersion: EnumMember | null)Target
Section titled “Target”Model | ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| addedVersion | EnumMember | null | The enum member representing the service version. |
@traitContext
Section titled “@traitContext”@traitContext sets the applicable context for a trait on its envelope property.
@Azure.Core.Traits.traitContext(contexts: EnumMember | Union | unknown)Target
Section titled “Target”The trait envelope property where the context will be applied.
ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| contexts | EnumMember | Union | unknown | An enum member or union of enum members representing the trait’s applicable contexts. |
@traitLocation
Section titled “@traitLocation”@traitLocation sets the applicable location for a trait on its envelope property.
@Azure.Core.Traits.traitLocation(contexts: EnumMember)Target
Section titled “Target”The trait envelope property where the context will be applied.
ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| contexts | EnumMember | An enum member or union of enum members representing the trait’s applicable contexts. |