Skip to content

Long-Running Operations

This doc details what emitters will generate for long-running operations.

Resource create or replace

Long-running operation to create or replace a resource.

alias ResourceOperations = global.Azure.Core.ResourceOperations<NoConditionalRequests &
NoRepeatableRequests &
NoClientRequestId>;
/** Details about a user. */
@resource("users")
model User {
/** The name of user. */
@key
@visibility("read")
name: string;
/** The role of user */
role: string;
}
// Operation for polling the status of the LRO. SDK may exclude this operation from client.
@sharedRoute
op getOperationStatus is ResourceOperations.GetResourceOperationStatus<User, never>;
@pollingOperation(getOperationStatus)
op createOrReplace is ResourceOperations.LongRunningResourceCreateOrReplace<User>;
def begin_create_or_replace(
self, name: str, resource: Union[User, JSON, IO[bytes]], **kwargs: Any
) -> LROPoller[User]

Resource delete

Long-running operation to delete a resource.

@pollingOperation(getOperationStatus)
op delete is ResourceOperations.LongRunningResourceDelete<User>;
def begin_delete(self, name: str, **kwargs: Any) -> LROPoller[None]

Resource action

Long-running operation to invoke an action on a resource.

/** Details about a user. */
@resource("users")
model User {
/** The name of user. */
@key
@visibility("read")
name: string;
/** The role of user */
role: string;
}
/** The parameters for exporting a user. */
model UserExportParams {
/** The format of the data. */
@query
format: string;
}
/** The exported user data. */
model ExportedUser {
/** The name of user. */
name: string;
/** The exported URI. */
resourceUri: string;
}
// Operation for polling the status of the LRO. SDK may exclude this operation from client.
@sharedRoute
op getExportOperationStatus is ResourceOperations.GetResourceOperationStatus<User, ExportedUser>;
@pollingOperation(getExportOperationStatus)
op export is ResourceOperations.LongRunningResourceAction<User, UserExportParams, ExportedUser>;
def begin_export(self, name: str, *, format: str, **kwargs: Any) -> LROPoller[ExportedUser]