TypeSpec Azure Resource Manager library
npm install @azure-tools/typespec-azure-resource-manager
Add the following in tspconfig.yaml
:
linter:
extends:
- "@azure-tools/typespec-azure-resource-manager/all"
Available ruleSets:
Name | Description |
---|---|
@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment |
@armResourceAction should not be used with @segment . |
@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property |
Warn about duplicate properties in resources. |
@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator |
Each resource interface must have an @armResourceOperations decorator. |
@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb |
Actions must be HTTP Post operations. |
@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property |
Check for invalid resource envelope properties. |
@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format |
Check for valid versions. |
@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars |
Arm resource key must contain only alphanumeric characters. |
@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response |
[RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. |
@azure-tools/typespec-azure-resource-manager/arm-resource-patch |
Validate ARM PATCH operations. |
@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars |
Arm resource name must contain only alphanumeric characters. |
@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state |
Check for properly configured provisioningState property. |
@azure-tools/typespec-azure-resource-manager/arm-common-types-version |
Specify the ARM common-types version using @armCommonTypesVersion. |
@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels |
Tracked Resources must use 3 or fewer levels of nesting. |
@azure-tools/typespec-azure-resource-manager/arm-resource-operation |
Validate ARM Resource operations. |
@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation |
Check for resources that must have a delete operation. |
@azure-tools/typespec-azure-resource-manager/empty-updateable-properties |
Should have updateable properties. |
@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation |
Tenant and Extension resources should not define a list by subscription operation. |
@azure-tools/typespec-azure-resource-manager/no-response-body |
The body of 202 response should be empty. |
@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint |
Check for missing Operations interface. |
@azure-tools/typespec-azure-resource-manager/patch-envelope |
Patch envelope properties should match the resource properties. |
@azure-tools/typespec-azure-resource-manager/resource-name |
Check the resource name. |
@azure-tools/typespec-azure-resource-manager/retry-after |
Check if retry-after header appears in response body. |
@azure-tools/typespec-azure-resource-manager/unsupported-type |
Check for unsupported ARM types. |
@armCommonTypesVersion
@armLibraryNamespace
@armProviderNamespace
@armProviderNameValue
@armRenameListByOperation
@armResourceAction
@armResourceCollectionAction
@armResourceCreateOrUpdate
@armResourceDelete
@armResourceList
@armResourceOperations
@armResourceRead
@armResourceUpdate
@extensionResource
@locationResource
@resourceGroupResource
@singleton
@subscriptionResource
@tenantResource
@useLibraryNamespace
This decorator is used either on a namespace or a version enum value to indicate the version of the ARM common-types to use for refs in emitted Swagger files.
@Azure.ResourceManager.armCommonTypesVersion(version: valueof string | EnumMember)
union Namespace | EnumMember
Name | Type | Description |
---|---|---|
version | valueof union string | EnumMember |
The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value. |
@armLibraryNamespace
designates a namespace as containign ARM Provider information.
@Azure.ResourceManager.armLibraryNamespace
Namespace
None
@armLibraryNamespace
namespace Microsoft.Contoso;
@armProviderNamespace
sets the ARM provider name. It will default to use the
Namespace element value unless an override value is specified.
@Azure.ResourceManager.armProviderNamespace(providerNamespace?: valueof string)
Namespace
Name | Type | Description |
---|---|---|
providerNamespace | valueof scalar string |
Provider namespace |
@armProviderNamespace
namespace Microsoft.Contoso;
@armProviderNamespace("Microsoft.Contoso")
namespace Microsoft.ContosoService;
@armResourceType
sets the value fo the decorated string
property to the type of the ARM resource.
@Azure.ResourceManager.armProviderNameValue
union Operation | Model
None
Marks the operation as being a collection action
@Azure.ResourceManager.armRenameListByOperation(resourceType: Model, parentTypeName?: valueof string, parentFriendlyTypeName?: valueof string)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource |
parentTypeName | valueof scalar string |
: Parent type name. |
parentFriendlyTypeName | valueof scalar string |
Friendly name for parent. |
@Azure.ResourceManager.armResourceAction(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
Marks the operation as being a collection action
@Azure.ResourceManager.armResourceCollectionAction
Operation
None
@Azure.ResourceManager.armResourceCreateOrUpdate(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
@Azure.ResourceManager.armResourceDelete(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
@Azure.ResourceManager.armResourceList(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
This decorator is used to identify interfaces containing resource operations.
When applied, it marks the interface with the @autoRoute
decorator so that
all of its contained operations will have their routes generated
automatically.
It also adds a @tag
decorator bearing the name of the interface so that all
of the operations will be grouped based on the interface name in generated
clients.
@Azure.ResourceManager.armResourceOperations(_?: unknown)
Interface
Name | Type | Description |
---|---|---|
_ | (intrinsic) unknown |
DEPRECATED |
@Azure.ResourceManager.armResourceRead(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
@Azure.ResourceManager.armResourceUpdate(resourceType: Model)
Operation
Name | Type | Description |
---|---|---|
resourceType | Model |
Resource model |
@extensionResource
marks an ARM resource model as an Extension resource.
Extension resource extends other resource types. URL path is appended
to another segment {scope} which refers to another Resource URL.
{resourceUri}/providers/Microsoft.Contoso/accessPermissions
See more details on different ARM resource type here.
@Azure.ResourceManager.extensionResource
Model
None
@locationResource
marks an ARM resource model as a location based resource.
Location based resources have REST API paths like
/subscriptions/{subscriptionId}/locations/{location}/providers/Microsoft.Contoso/employees
See more details on different ARM resource type here.
@Azure.ResourceManager.locationResource
Model
None
@resourceGroupResource
marks an ARM resource model as a resource group level resource.
This is the default option for ARM resources. It is provided for symmetry and clarity, and
you typically do not need to specify it.
/subscription/{id}/resourcegroups/{rg}/providers/Microsoft.Contoso/employees
See more details on different ARM resource type here.
@Azure.ResourceManager.resourceGroupResource
Model
None
@singleton
marks an ARM resource model as a singleton resource.
Singleton resources only have a single instance with a fixed key name.
.../providers/Microsoft.Contoso/monthlyReports/default
See more details on different ARM resource type here.
@Azure.ResourceManager.singleton(keyValue?: valueof string | default)
Model
Name | Type | Description |
---|---|---|
keyValue | valueof union string | default |
The name of the singleton resource. Default name is "default". |
@subscriptionResource
marks an ARM resource model as a subscription resource.
Subscription resources have REST API paths like:
/subscription/{id}/providers/Microsoft.Contoso/employees
See more details on different ARM resource type here.
@Azure.ResourceManager.subscriptionResource
Model
None
@tenantResource
marks an ARM resource model as a Tenant resource/Root resource/Top-Level resource.
Tenant resources have REST API paths like:
/provider/Microsoft.Contoso/FooResources
See more details on different ARM resource type here.
@Azure.ResourceManager.tenantResource
Model
None
Declare the ARM library namespaces used in this provider. This allows sharing ARM resource types across specifications
@Azure.ResourceManager.useLibraryNamespace(...namespaces: Namespace[])
Namespace
Name | Type | Description |
---|---|---|
namespaces | model Namespace[] |
The namespaces of arm libraries used in this provider |