From 62f1a7e2396bf97433433c973f7d86c19fb28b5e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 21:22:34 +0000 Subject: [PATCH 1/2] Initial plan From 342e81951ee9a5cb8a1203b42169cb4feb60954f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 21:26:58 +0000 Subject: [PATCH 2/2] Document handling failed long-running operations in azure-core README Co-authored-by: vcolin7 <5799331+vcolin7@users.noreply.github.com> --- sdk/core/azure-core/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sdk/core/azure-core/README.md b/sdk/core/azure-core/README.md index d6092ac6c874..8e1491b5ff35 100644 --- a/sdk/core/azure-core/README.md +++ b/sdk/core/azure-core/README.md @@ -114,6 +114,31 @@ consumer requests more data until the consumer finishes processing or all pages `PollerFlux` manages sending an initial service request and requesting processing updates on a fix interval until polling is cancelled or reaches a terminal state. +#### Handling a failed long-running operation + +When a long-running operation reaches a terminal state that indicates failure +(`LongRunningOperationStatus.FAILED`), requesting the final result throws an exception describing the failure, +rather than returning a value. For the synchronous `SyncPoller`, `waitForCompletion()` and `getFinalResult()` +will throw once the operation completes unsuccessfully: + +```java +SyncPoller poller = client.beginLongRunningOperation(); +try { + ResultType result = poller.getFinalResult(); +} catch (RuntimeException exception) { + // The exception (or its cause) carries the failure details reported by the service, e.g. an + // HttpResponseException, or a service-specific subtype such as ManagementException for Azure Resource + // Manager operations, which exposes the error code and message returned by the service. +} +``` + +For the asynchronous `PollerFlux`, the `Mono` returned from `.last().flatMap(AsyncPollResponse::getFinalResult)` +(or the equivalent obtained by converting to a `SyncPoller`) emits an error signal instead of a value when the +operation fails, so handle it with the usual reactive operators, such as `onErrorResume` or `doOnError`. + +If you'd rather react to a failure without waiting for an exception to be thrown, you can inspect each +`PollResponse`/`AsyncPollResponse` as it's emitted and compare `getStatus()` to `LongRunningOperationStatus.FAILED`. + ### Configuring Builders Builders are used to create service clients and some `TokenCredential` implementations. They can be configured with a