You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The client sends the request to initiate the long-running operation.
179
179
The initial request could be a POST or DELETE method.
180
-
The request may contain an `operation-id` header that the service uses as the ID of the status monitor created for the operation.
180
+
The request may contain an `Operation-Id` header that the service uses as the ID of the status monitor created for the operation.
181
181
182
182
2. The service validates the request and initiates the operation processing.
183
183
If there are any problems with the request, the service responds with a `4xx` status code and error response body.
@@ -199,25 +199,26 @@ If the operation is still being processed, the status field will contain a "non-
199
199
200
200
5. After the operation processing completes, a GET request to the status monitor returns the status monitor with a status field set to a terminal value -- `Succeeded`, `Failed`, or `Canceled` -- that indicates the result of the operation.
201
201
If the status is `Failed`, the status monitor resource contains an `error` field with a `code` and `message` that describes the failure.
202
-
If the status is `Succeeded` and the LRO is an Action operation, the operation results will be returned in the `results` field of the status monitor.
202
+
If the status is `Succeeded` and the LRO is an Action operation, the operation results will be returned in the `result` field of the status monitor.
203
203
If the status is `Succeeded` and the LRO is an operation on a resource, the client can perform a GET on the resource
204
204
to observe the result of the operation if desired.
205
205
206
206
6. There may be some cases where a long-running operation can be completed before the response to the initial request.
207
207
In these cases, the operation should still return a `202 Accepted` with the `status` property set to the appropriate terminal state.
208
208
209
-
7. The service will auto-purge the status monitor resource after completion (at least 24 hours).
209
+
7. The service is responsible for purging the status-monitor resource.
210
+
It should auto-purge the status monitor resource after completion (at least 24 hours).
210
211
The service may offer DELETE of the status monitor resource due to GDPR/privacy.
211
212
212
213
### Long-running Action Operations
213
214
214
215
An action operation that is also long-running combines the [Action Operations](#action-operations) pattern
215
216
with the [Long Running Operations](#long-running-operations) pattern.
216
217
217
-
The operation is initiated with a POST operation and the operation path ends in `:action`.
218
+
The operation is initiated with a POST operation and the operation path ends in `:<action>`.
218
219
219
220
```text
220
-
POST /<service-or-resource-url>:action?api-version=2022-05-01
221
+
POST /<service-or-resource-url>:<action>?api-version=2022-05-01
221
222
Operation-Id: 22
222
223
223
224
{
@@ -231,7 +232,6 @@ The response is a `202 Accepted` as described above.
| 2022-May-20| Update guidance on long-running operations |
9
+
| 2022-Jun-08| Update guidance on long-running operations |
10
10
| 2022-May-11 | Drop guidance on version discovery |
11
11
| 2022-Mar-29 | Add guidelines about using durations |
12
12
| 2022-Mar-25 | Update guideline for date values in headers to follow RFC 7231 |
@@ -765,14 +765,15 @@ Considerations for Service Design for an introduction to the design of long-runn
765
765
766
766
:white_check_mark:**DO** implement an operation as an LRO if the 99th percentile response time is greater than 1s.
767
767
768
-
:no_entry:**DO NOT** implement PATCH as an LRO. If LRO update is required it should be implemented with POST.
768
+
:no_entry:**DO NOT** implement PATCH as an LRO. If LRO update is required it must be implemented with POST.
769
769
770
770
In rare instances where an operation may take a _very long_ time to complete, e.g. longer than 15 minutes,
771
771
it may be better to expose this as a first class resource of the API rather than as an operation on another resource.
772
772
773
773
There are two basic patterns for long-running operations in Azure. The first pattern is used for a POST and DELETE
774
774
operations that initiate the LRO. These return a `202 Accepted` response with a JSON status monitor in the response body.
775
775
The second pattern applies only in the case of a PUT operation to create a resource that also involves additional long-running processing.
776
+
For guidance on when to use a specific pattern, please refer to [Considerations for Service Design, Long Running Operations](./ConsiderationsForServiceDesign.md#long-running-operations).
776
777
These are described in the following two sections.
777
778
778
779
#### POST or DELETE LRO pattern
@@ -794,8 +795,6 @@ a [status monitor](https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3)
794
795
795
796
:warning:**YOU SHOULD NOT** return any other `2xx` status code from the initial request of an LRO -- return `202-Accepted` and a status monitor even if processing was completed before the initiating request returns.
796
797
797
-
:white_check_mark:**DO** include a `Retry-After` header in the response to the initiating request if the operation is not complete. The value of this header should be an integer number of seconds to wait before making the first request to the status monitor.
798
-
799
798
:ballot_box_with_check:**YOU SHOULD** include an `Operation-Location` header in the response with the absolute URL of the status monitor for the operation, but do not include an api-version query parameter.
800
799
801
800
:white_check_mark:**DO** return a status monitor in the response body as described in [Status and results of long-running operations](#status-and-results-of-long-running-operations).
@@ -818,8 +817,6 @@ For a PUT (create or replace) with additional long-running processing:
818
817
819
818
:white_check_mark:**DO** include response headers with any additional values needed for a GET request to the status monitor (e.g. location).
820
819
821
-
:white_check_mark:**DO** include a `Retry-After` header in the response to the initiating request if the operation is not complete. The value of this header should be an integer number of seconds to wait before making the first request to the status monitor.
822
-
823
820
:ballot_box_with_check:**YOU SHOULD** include an `Operation-Location` header in the response with the absolute URL of the status monitor for the operation, but do not include an api-version query parameter.
824
821
825
822
#### Obtaining status and results of long-running operations
@@ -835,18 +832,20 @@ For all long-running operations, the client will issue a GET on a status monitor
835
832
Property | Type | Required | Description
836
833
-------- | ----------- | :------: | -----------
837
834
`id` | string | true | The unique id of the operation
838
-
other | | true | Other values needed for a GET request to the status monitor (e.g. location)
839
835
`status` | string | true | enum that includes terminal values "Succeeded", "Failed", "Canceled"
840
836
`error` | ErrorDetail | | Error object that describes the error when status is "Failed"
841
837
`result` | object | | Only for POST action-type LRO, the results of the operation when completed successfully
838
+
additional<br/>properties | | | Additional named or dynamic properties of the operation
839
+
840
+
:white_check_mark:**DO** include the `id` of the operation and any other values needed for the client to form a GET request to the status monitor (e.g. a `location` path parameter).
842
841
843
842
:white_check_mark:**DO** include a `Retry-After` header in the response to GET requests to the status monitor if the operation is not complete. The value of this header should be an integer number of seconds to wait before making the next request to the status monitor.
844
843
845
844
:white_check_mark:**DO** include the `result` property (if any) in the status monitor for a POST action-type long-running operation when the operation completes successfully.
846
845
847
846
:no_entry:**DO NOT** include a `result` property in the status monitor for a long-running operation that is not a POST action-type long-running operation.
848
847
849
-
:white_check_mark:**DO** retain the status monitor resource for some documented period of time (at least 24 hours) after the operation completes.
848
+
:white_check_mark:**DO** retain the status monitor resource for some publicly documented period of time (at least 24 hours) after the operation completes.
850
849
851
850
### Bring your own Storage
852
851
When implementing your service, it is very common to store and retrieve data and files. When you encounter this scenario, avoid implementing your own storage strategy and instead use Azure Bring Your Own Storage (BYOS). BYOS provides significant benefits to service implementors, e.g. security, an aggressively optimized frontend, uptime, etc.
*[Breaking Changes](http://aka.ms/AzBreakingChangesPolicy/) <sub>Note: Internal Microsoft link</sub>
9
9
10
-
You can reach out to use via [email](mailto://[email protected]) or in our [Teams](https://teams.microsoft.com/l/team/19%3a3ebb18fded0e47938f998e196a52952f%40thread.tacv2/conversations?groupId=1a10b50c-e870-4fe0-8483-bf5542a8d2d8&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47) channel.
10
+
You can reach out to us via [email](mailto://[email protected]) or in our [Teams](https://teams.microsoft.com/l/team/19%3a3ebb18fded0e47938f998e196a52952f%40thread.tacv2/conversations?groupId=1a10b50c-e870-4fe0-8483-bf5542a8d2d8&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47) channel.
11
11
12
12
<sub>Note: The Teams channel is internal MS.</sup>
0 commit comments