Skip to content

November 2022

Release Notes for November 2022 (2022-11-11)

[TypeSpec] Azure.Core and Azure.ResourceManager updated TResource template parameter constraint

Most of the interface types in these packages(e.g. Page, ResourceCreateOrUpdate, GetResourceOperationStatus , etc.) have been updated to have a constraint on the TResource template parameter. It must now be an object. This was already validated by the requirement for presence of @resource but this means that it is a built in complier validation.

In most cases this shouldn’t affect you as you will already be passing an object to one of those templates. However if you defined your own template expecting a TResource that would be referencing one of those updated templates you will get an error. This can be resolved by defining the same constraint on your own parameter by adding extends object

Before

model MyCustomPage<T> is Page<T>;

After

model MyCustomPage<T extends object> is Page<T>;

[TypeSpec] Azure.ResourceManager added lint rules to enforce consistent response schema and @armResource<Operation> decorators’ usage

@armResource<Operation> decorators’ usage

For ARM resource operations definition, the op must be decorated with @armResource<Operation>. More specifically,

  • put: @armResourceCreateOrUpdate
  • get: @armResourceRead or @armResourceList
  • patch: @armResourceUpdate
  • delete: @armResourceDelete
  • post: @armResourceAction

Before

@post
GiveRaise(...ResourceInstanceParameters<Employee>): ArmResponse<Employee> | ErrorResponse;

After

@post
@armResourceAction(Employee)
GiveRaise(...ResourceInstanceParameters<Employee>): ArmResponse<Employee> | ErrorResponse;

ARM RPC008 rule

The response model of put, get, patch, list is enforced to be same with resource model.

Before

@get @armResourceRead(FooResource) read(...ResourceInstanceParameters<FooResource>): ArmResponse<AnotherFooResource> | ErrorResponse;

After

@get @armResourceRead(FooResource) read(...ResourceInstanceParameters<FooResource>): ArmResponse<FooResource> | ErrorResponse;

To resolve the lint issues, you can add the missing decorators or use the same resource model in response. However, the recommended way is to extend ARM operation templates on interface, for example:

using Azure.ResourceManager;
@armResourceOperations
interface FooResourcess extends ResourceOperations<FooResource, FooProperties> {}