|
| 1 | +--- |
| 2 | +title: Azure Maps long-running operation API V2 |
| 3 | +description: Learn about long-running asynchronous V2 background processing in Azure Maps |
| 4 | +author: anastasia-ms |
| 5 | +ms.author: v-stharr |
| 6 | +ms.date: 05/18/2021 |
| 7 | +ms.topic: conceptual |
| 8 | +ms.service: azure-maps |
| 9 | +services: azure-maps |
| 10 | +manager: philmea |
| 11 | +ms.custom: mvc |
| 12 | +--- |
| 13 | + |
| 14 | +# Creator Long-Running Operation API V2 |
| 15 | + |
| 16 | +Some APIs in Azure Maps use an [Asynchronous Request-Reply pattern](/azure/architecture/patterns/async-request-reply). This pattern allows Azure Maps to provide highly available and responsive services. This article explains Azure Map's specific implementation of long-running asynchronous background processing. |
| 17 | + |
| 18 | +## Submit a request |
| 19 | + |
| 20 | +A client application starts a long-running operation through a synchronous call to an HTTP API. Typically, this call is in the form of an HTTP POST request. When an asynchronous workload is successfully created, the API will return an HTTP `202` status code, indicating that the request has been accepted. This response contains a `Location` header pointing to an endpoint that the client can poll to check the status of the long-running operation. |
| 21 | + |
| 22 | +### Example of a success response |
| 23 | + |
| 24 | +```HTTP |
| 25 | +Status: 202 Accepted |
| 26 | +Operation-Location: https://atlas.microsoft.com/service/operations/{operationId} |
| 27 | +
|
| 28 | +``` |
| 29 | + |
| 30 | +If the call doesn't pass validation, the API will instead return an HTTP `400` response for a Bad Request. The response body will provide the client more information on why the request was invalid. |
| 31 | + |
| 32 | +### Monitor the operation status |
| 33 | + |
| 34 | +The location endpoint provided in the accepted response headers can be polled to check the status of the long-running operation. The response body from operation status request will always contain the `status` and the `created` properties. The `status` property shows the current state of the long-running operation. Possible states include `"NotStarted"`, `"Running"`, `"Succeeded"`, and `"Failed"`. The `created` property shows the time the initial request was made to start the long-running operation. When the state is either `"NotStarted"` or `"Running"`, a `Retry-After` header will also be provided with the response. The `Retry-After` header, measured in seconds, can be used to determine when the next polling call to the operation status API should be made. |
| 35 | + |
| 36 | +### Example of running a status response |
| 37 | + |
| 38 | +```HTTP |
| 39 | +Status: 200 OK |
| 40 | +Retry-After: 30 |
| 41 | +{ |
| 42 | + "operationId": "c587574e-add9-4ef7-9788-1635bed9a87e", |
| 43 | + "created": "3/11/2020 8:45:13 PM +00:00", |
| 44 | + "status": "Running" |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Handle operation completion |
| 49 | + |
| 50 | +Upon completing the long-running operation, the status of the response will either be `"Succeeded"` or `"Failed"`. All responses will return an HTTP 200 OK code. When a new resource has been created from a long-running operation, the response will also contain a `Resource-Location` header that points to metadata about the resource. Upon a failure, the response will have an `error` property in the body. The error data adheres to the OData error specification. |
| 51 | + |
| 52 | +### Example of success response |
| 53 | + |
| 54 | +```HTTP |
| 55 | +Status: 200 OK |
| 56 | +Resource-Location: "https://atlas.microsoft.com/tileset/{tileset-id}" |
| 57 | + { |
| 58 | + "operationId": "c587574e-add9-4ef7-9788-1635bed9a87e", |
| 59 | + "created": "2021-05-06T07:55:19.5256829+00:00", |
| 60 | + "status": "Succeeded" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +### Example of failure response |
| 65 | + |
| 66 | +```HTTP |
| 67 | +Status: 200 OK |
| 68 | +
|
| 69 | +{ |
| 70 | + "operationId": "c587574e-add9-4ef7-9788-1635bed9a87e", |
| 71 | + "created": "3/11/2020 8:45:13 PM +00:00", |
| 72 | + "status": "Failed", |
| 73 | + "error": { |
| 74 | + "code": "InvalidFeature", |
| 75 | + "message": "The provided feature is invalid.", |
| 76 | + "details": { |
| 77 | + "code": "NoGeometry", |
| 78 | + "message": "No geometry was provided with the feature." |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
0 commit comments