Skip to content

Commit f3e08f2

Browse files
committed
Address comments in PR and working session on LRO guidelines
1 parent c350ae0 commit f3e08f2

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

azure/ConsiderationsForServiceDesign.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
| Date | Notes |
88
| ----------- | -------------------------------------------------------------- |
9-
| 2022-May-20 | Update guidance on long-running operations |
9+
| 2022-Jun-08 | Update guidance on long-running operations |
1010
| 2022-Feb-01 | Updated error guidance |
1111
| 2021-Sep-11 | Add long-running operations guidance |
1212
| 2021-Aug-06 | Updated Azure REST Guidelines per Azure API Stewardship Board. |
@@ -168,7 +168,7 @@ sequenceDiagram
168168
participant API Endpoint
169169
participant Status Monitor
170170
Client->>API Endpoint: POST/DELETE
171-
API Endpoint->>Client: HTTP/1.1 202 Accepted<br/>Retry-After: 5<br/>{ "id": "22", "status": "NotStarted" }
171+
API Endpoint->>Client: HTTP/1.1 202 Accepted<br/>{ "id": "22", "status": "NotStarted" }
172172
Client->>Status Monitor: GET
173173
Status Monitor->>Client: HTTP/1.1 200 OK<br/>Retry-After: 5<br/>{ "id": "22", "status": "Running" }
174174
Client->>Status Monitor: GET
@@ -177,7 +177,7 @@ sequenceDiagram
177177

178178
1. The client sends the request to initiate the long-running operation.
179179
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.
181181

182182
2. The service validates the request and initiates the operation processing.
183183
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-
199199

200200
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.
201201
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.
203203
If the status is `Succeeded` and the LRO is an operation on a resource, the client can perform a GET on the resource
204204
to observe the result of the operation if desired.
205205

206206
6. There may be some cases where a long-running operation can be completed before the response to the initial request.
207207
In these cases, the operation should still return a `202 Accepted` with the `status` property set to the appropriate terminal state.
208208

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).
210211
The service may offer DELETE of the status monitor resource due to GDPR/privacy.
211212

212213
### Long-running Action Operations
213214

214215
An action operation that is also long-running combines the [Action Operations](#action-operations) pattern
215216
with the [Long Running Operations](#long-running-operations) pattern.
216217

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>`.
218219

219220
```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
221222
Operation-Id: 22
222223
223224
{
@@ -231,7 +232,6 @@ The response is a `202 Accepted` as described above.
231232
```text
232233
HTTP/1.1 202 Accepted
233234
Operation-Location: https://<status-monitor-endpoint>/22
234-
Retry-After: 5
235235
236236
{
237237
"id": "22",
@@ -262,7 +262,7 @@ HTTP/1.1 200 OK
262262
A special case of long-running operation that occurs often is a PUT operation to create or replace a resource
263263
that involves some additional long-running processing.
264264
One example is a resource requires physical resources (e.g. servers) to be "provisioned" to make the resource functional.
265-
In this case, the request may contain an `operation-id` header that the service will use as
265+
In this case, the request may contain an `Operation-Id` header that the service will use as
266266
the ID of the status monitor created for the operation.
267267

268268
```text
@@ -314,7 +314,8 @@ HTTP/1.1 200 OK
314314
}
315315
```
316316

317-
If the additional processing failed, the service may delete the original resource if it is not usable in this state.
317+
If the additional processing failed, the service may delete the original resource if it is not usable in this state,
318+
but would have to clearly document this behavior.
318319

319320
### Long-running delete operation
320321

@@ -328,7 +329,7 @@ When the delete operation completes successfully, a client must be able to creat
328329
### Controlling a long-running operation
329330

330331
It might be necessary to support some control action on a long-running operation, such as cancel.
331-
This is implemented as a POST on the status monitor endpoint with `:action` added.
332+
This is implemented as a POST on the status monitor endpoint with `:<action>` added.
332333

333334
```text
334335
POST /<status-monitor-url>:cancel?api-version=2022-05-01

azure/Guidelines.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
| Date | Notes |
88
| ----------- | -------------------------------------------------------------- |
9-
| 2022-May-20 | Update guidance on long-running operations |
9+
| 2022-Jun-08 | Update guidance on long-running operations |
1010
| 2022-May-11 | Drop guidance on version discovery |
1111
| 2022-Mar-29 | Add guidelines about using durations |
1212
| 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
765765

766766
:white_check_mark: **DO** implement an operation as an LRO if the 99th percentile response time is greater than 1s.
767767

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.
769769

770770
In rare instances where an operation may take a _very long_ time to complete, e.g. longer than 15 minutes,
771771
it may be better to expose this as a first class resource of the API rather than as an operation on another resource.
772772

773773
There are two basic patterns for long-running operations in Azure. The first pattern is used for a POST and DELETE
774774
operations that initiate the LRO. These return a `202 Accepted` response with a JSON status monitor in the response body.
775775
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).
776777
These are described in the following two sections.
777778

778779
#### POST or DELETE LRO pattern
@@ -794,8 +795,6 @@ a [status monitor](https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3)
794795

795796
: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.
796797

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-
799798
: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.
800799

801800
: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:
818817

819818
:white_check_mark: **DO** include response headers with any additional values needed for a GET request to the status monitor (e.g. location).
820819

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-
823820
: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.
824821

825822
#### 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
835832
Property | Type | Required | Description
836833
-------- | ----------- | :------: | -----------
837834
`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)
839835
`status` | string | true | enum that includes terminal values "Succeeded", "Failed", "Canceled"
840836
`error` | ErrorDetail | | Error object that describes the error when status is "Failed"
841837
`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).
842841

843842
: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.
844843

845844
: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.
846845

847846
: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.
848847

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.
850849

851850
### Bring your own Storage
852851
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.

azure/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Designing powerful APIs with strong defaults, consistent behavior across related
77
* [OpenAPI Style Guidelines](https://github.com/Azure/azure-api-style-guide/blob/main/README.md)
88
* [Breaking Changes](http://aka.ms/AzBreakingChangesPolicy/) <sub>Note: Internal Microsoft link</sub>
99

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.
1111

1212
<sub>Note: The Teams channel is internal MS.</sup>

0 commit comments

Comments
 (0)