Skip to content

Commit 2ea135d

Browse files
authored
Merge pull request #491 from microsoft/corranrogue9/lropermissions
Add guidance for crafting LRO permissions
2 parents e449c4f + 3fcd0f3 commit 2ea135d

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

graph/patterns/long-running-operations.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ There are some deviations from the base guidelines where Microsoft Graph API sta
5757
- The API response says the operation resource is being created at the URL provided in the Location header and indicates that the request is not completed by including a 202 status code.
5858
- Microsoft Graph doesn’t allow tenant-wide operation resources; therefore, stepwise operations are often modeled as a navigation property on the target resource.
5959

60+
- For most implementations of the LRO pattern (like the example above), there will be 3 permissions necessary to comply with the principle of least privilege: `ArchiveOperation.ReadWrite.All` to create the `archiveOperation` entity, `ArchiveOperation.Read.All` to track the `archiveOperation` entity to completion, and `Archives.Read.All` to retrieve the `archive` that was created as a result of the operation.
61+
For APIs that would have been modeled as a simple `GET` on the resource URL, but that are modeled as long-running operations due to MSGraph performance requirements, only the `Archive.Read.All` permission is necessary as long as creating the `archiveOperation` entity is "safe".
62+
Here, "safe" means that there are no side effects of creating the `archiveOperation` entity that would change the functionality of any entities outside of the `archive` being retrieved.
63+
This requirment does not mean that the API must be idempotent, but an idempotent API is suffucient to meet this requirement.
64+
6065
## When to use this pattern
6166

6267
Any API call that is expected to take longer than one second in the 99th percentile should use the long running operations pattern.
@@ -103,7 +108,7 @@ A client wants to provision a new database:
103108
POST https://graph.microsoft.com/v1.0/storage/databases/
104109
105110
{
106-
"displayName": "Retail DB",
111+
"displayName": "Retail DB",
107112
}
108113
```
109114

@@ -116,10 +121,10 @@ HTTP/1.1 201 Created
116121
Location: https://graph.microsoft.com/v1.0/storage/databases/db1
117122
118123
{
119-
"id": "db1",
120-
"displayName": "Retail DB",
121-
"status": "provisioning",
122-
[ … other fields for "database" …]
124+
"id": "db1",
125+
"displayName": "Retail DB",
126+
"status": "provisioning",
127+
[ … other fields for "database" …]
123128
}
124129
```
125130

@@ -130,10 +135,10 @@ GET https://graph.microsoft.com/v1.0/storage/databases/db1
130135
131136
HTTP/1.1 200 Ok
132137
{
133-
"id": "db1",
134-
"displayName": "Retail DB",
135-
"status": "succeeded",
136-
[ … other fields for "database" …]
138+
"id": "db1",
139+
"displayName": "Retail DB",
140+
"status": "succeeded",
141+
[ … other fields for "database" …]
137142
}
138143
```
139144

@@ -156,10 +161,10 @@ HTTP/1.1 202 Accepted
156161
Retry-After: 30
157162
158163
{
159-
"id": "db1",
160-
"displayName": "Retail DB",
161-
"status": "deleting",
162-
[ … other fields for "database" …]
164+
"id": "db1",
165+
"displayName": "Retail DB",
166+
"status": "deleting",
167+
[ … other fields for "database" …]
163168
}
164169
```
165170

@@ -176,8 +181,8 @@ HTTP/1.1 404 Not Found
176181
POST https://graph.microsoft.com/v1.0/storage/archives/
177182
178183
{
179-
"displayName": "Image Archive",
180-
...
184+
"displayName": "Image Archive",
185+
...
181186
}
182187
```
183188

@@ -206,9 +211,9 @@ HTTP/1.1 200 OK
206211
Retry-After: 30
207212
208213
{
209-
"createdDateTime": "2015-06-19T12-01-03.4Z",
210-
"lastActionDateTime": "2015-06-19T12-01-03.45Z",
211-
"status": "running"
214+
"createdDateTime": "2015-06-19T12-01-03.4Z",
215+
"lastActionDateTime": "2015-06-19T12-01-03.45Z",
216+
"status": "running"
212217
}
213218
```
214219

@@ -227,10 +232,10 @@ location:
227232
HTTP/1.1 200 OK
228233
229234
{
230-
"createdDateTime": "2015-06-19T12-01-03.45Z",
231-
"lastActionDateTime": "2015-06-19T12-06-03.0024Z",
232-
"status": "succeeded",
233-
"resourceLocation": "https://graph.microsoft.com/v1.0/storage/archives/987"
235+
"createdDateTime": "2015-06-19T12-01-03.45Z",
236+
"lastActionDateTime": "2015-06-19T12-06-03.0024Z",
237+
"status": "succeeded",
238+
"resourceLocation": "https://graph.microsoft.com/v1.0/storage/archives/987"
234239
}
235240
```
236241

@@ -240,8 +245,8 @@ HTTP/1.1 200 OK
240245
POST https://graph.microsoft.com/v1.0/storage/copyArchive
241246
242247
{
243-
"displayName": "Image Archive",
244-
"destination": "Second-tier storage"
248+
"displayName": "Image Archive",
249+
"destination": "Second-tier storage"
245250
...
246251
}
247252
```
@@ -254,4 +259,4 @@ HTTP/1.1 202 Accepted
254259
255260
Location: https://graph.microsoft.com/v1.0/storage/operations/123
256261
257-
```
262+
```

0 commit comments

Comments
 (0)