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
Copy file name to clipboardExpand all lines: azure/Guidelines.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ This document offers prescriptive guidance labeled as follows:
59
59
## Building Blocks: HTTP, REST, & JSON
60
60
The Microsoft Azure Cloud platform exposes its APIs through the core building blocks of the Internet; namely HTTP, REST, and JSON. This section provides you with a general understanding of how these technologies should be applied when creating your service.
61
61
62
+
<aname="http"></a>
62
63
### HTTP
63
64
Azure services must adhere to the HTTP specification, [RFC7231](https://tools.ietf.org/html/rfc7231). This section further refines and constrains how service implementors should apply the constructs defined in the HTTP specification. It is therefore, important that you have a firm understanding of the following concepts:
64
65
@@ -260,6 +261,7 @@ Your service should include the `x-ms-request-id` value in error logs so that us
-[Why isn't HTTP PUT allowed to do partial updates in a REST API?](https://stackoverflow.com/questions/19732423/why-isnt-http-put-allowed-to-do-partial-updates-in-a-rest-api)
262
263
264
+
<aname="rest"></a>
263
265
### REpresentational State Transfer (REST)
264
266
REST is an architectural style with broad reach that emphasizes scalability, generality, independent deployment, reduced latency via caching, and security. When applying REST to your API, you define your service’s resources as a collections of items.
265
267
These are typically the nouns you use in the vocabulary of your service. Your service's [URLs](#uniform-resource-locators-urls) determine the hierarchical path developers use to perform CRUD (create, read, update, and delete) operations on resources. Note, it's important to model resource state, not behavior.
@@ -273,7 +275,7 @@ When designing your service, it is important to optimize for the developer using
273
275
<aname="rest-paths-make-sense"></a>
274
276
:white_check_mark:**DO** ensure your resource paths make sense
275
277
276
-
<aname="rest-simpify-operations"></a>
278
+
<aname="rest-simplify-operations"></a>
277
279
:white_check_mark:**DO** simplify operations with few required query parameters & JSON fields
:warning:**YOU SHOULD NOT** document specific error status codes in your OpenAPI/Swagger spec unless the "default" response cannot properly describe the specific error response (e.g. body schema is different).
427
429
430
+
<aname="json"></a>
428
431
### JSON
429
432
430
433
<aname="json-field-name-casing"></a>
@@ -539,6 +542,7 @@ Both Rectangle and Circle have common fields: `kind`, `fillColor`, `lineColor`,
539
542
540
543
## Common API Patterns
541
544
545
+
<aname="actions"></a>
542
546
### Performing an Action
543
547
The REST specification is used to model the state of a resource, and is primarily intended to handle CRUD (Create, Read, Update, Delete) operations. However, many services require the ability to perform an action on a resource, e.g. getting the thumbnail of an image or rebooting a VM. It is also sometimes useful to perform an action on a collection.
544
548
@@ -583,6 +587,7 @@ Note: To avoid potential collision of actions and resource ids, you should disal
583
587
<aname="actions-no-actions-for-crud"></a>
584
588
:no_entry:**DO NOT** use an action operation when the operation behavior could reasonably be defined as one of the standard REST Create, Read, Update, Delete, or List operations.
585
589
590
+
<aname="collections"></a>
586
591
### Collections
587
592
<aname="collections-response-is-object"></a>
588
593
:white_check_mark:**DO** structure the response to a list operation as an object with a top-level array field containing the set (or subset) of resources.
:white_check_mark:**DO** make clear in documentation of the `maxpagesize` parameter that the operation may choose to return fewer resources than the value specified.
833
838
839
+
<aname="versioning"></a>
834
840
### API Versioning
835
841
836
842
Azure services need to change over time. However, when changing a service, there are 2 requirements:
@@ -895,6 +901,7 @@ While removing a value from an enum is a breaking change, adding value to an enu
895
901
<aname="versioning-use-extensible-enums"></a>
896
902
:ballot_box_with_check:**You SHOULD** use extensible enums unless you are positive that the symbol set will **NEVER** change over time.
897
903
904
+
<aname="deprecation"></a>
898
905
### Deprecating Behavior Notification
899
906
900
907
When the [API Versioning](#API-Versioning) guidance above cannot be followed and the [Azure Breaking Change Reviewers](mailto:[email protected]) approve a [breaking change](#123-definition-of-a-breaking-change) to a specific API version it must be communicated to its callers. The API version that is being deprecated must add the `azure-deprecating` response header with a semicolon-delimited string notifying the caller what is being deprecated, when it will no longer function, and a URL linking to more information such as what new operation they should use instead.
@@ -926,6 +933,7 @@ azure-deprecating: API version 2009-27-07 will retire on 2022-12-01 (https://azu
926
933
<aname="deprecation-header-review"></a>
927
934
:no_entry:**DO NOT** introduce this header without approval from [Azure Breaking Change Reviewers](mailto:[email protected]) and an official deprecation notice on [Azure Updates](https://azure.microsoft.com/updates/).
928
935
936
+
<aname="repeatability"></a>
929
937
### Repeatability of requests
930
938
931
939
The ability to retry failed requests for which a client never received a response greatly simplifies the ability to write resilient distributed applications. While HTTP designates some methods as safe and/or idempotent (and thus retryable), being able to retry other operations such as create-using-POST-to-collection is desirable.
@@ -937,6 +945,7 @@ The ability to retry failed requests for which a client never received a respons
937
945
- A service advertises support for repeatability requests by adding the `Repeatability-First-Sent` and `Repeatability-Request-ID` to the set of headers for a given operation.
938
946
- When understood, all endpoints co-located behind a DNS name **MUST** understand the header. This means that a service **MUST NOT** ignore the presence of a header for any endpoints behind the DNS name, but rather fail the request containing a `Repeatability-Request-ID` header if that particular endpoint lacks support for repeatable requests. Such partial support **SHOULD** be avoided due to the confusion it causes for clients.
939
947
948
+
<aname="lro"></a>
940
949
### Long-Running Operations & Jobs
941
950
942
951
When the processing for an operation may take a significant amount of time to complete, it should be
@@ -1065,6 +1074,7 @@ additional<br/>properties | | | Additional named or dynamic properties of th
1065
1074
<aname="lro-status-monitor-retention"></a>
1066
1075
:white_check_mark:**DO** retain the status monitor resource for some publicly documented period of time (at least 24 hours) after the operation completes.
1067
1076
1077
+
<aname="byos"></a>
1068
1078
### Bring your own Storage (BYOS)
1069
1079
Many services need to store and retrieve data files. For this scenario, the service should not implement its own
1070
1080
storage APIs and should instead leverage the existing Azure Storage service. When doing this, the customer
@@ -1161,6 +1171,7 @@ Depending on the requirements of the service, there can be any number of "input"
1161
1171
<aname="byos-sas-for-output-location"></a>
1162
1172
:white_check_mark:**DO** support a "location" URL with a container-scoped SAS that has a minimum of `write` permissions for output directories.
1163
1173
1174
+
<aname="condreq"></a>
1164
1175
### Conditional Requests
1165
1176
When designing an API, you will almost certainly have to manage how your resource is updated. For example, if your resource is a bank account, you will want to ensure that one transaction--say depositing money--does not overwrite a previous transaction.
1166
1177
Similarly, it could be very expensive to send a resource to a client. This could be because of its size, network conditions, or a myriad of other reasons. To enable this level of control, services should leverage an `ETag` header, or "entity tag," which will identify the 'version' or 'instance' of the resource a particular client is working with.
@@ -1240,6 +1251,7 @@ While it may be tempting to use a revision/version number for the resource as th
1240
1251
<aname="condreq-etag-depends-on-encoding"></a>
1241
1252
:white_check_box: **DO**, when supporting multiple representations (e.g. Content-Encodings) for the same resource, generate different ETag values for the different representations.
1242
1253
1254
+
<aname="telemetry"></a>
1243
1255
### Distributed Tracing & Telemetry
1244
1256
Azure SDK client guidelines specify that client libraries must send telemetry data through the `User-Agent` header, `X-MS-UserAgent` header, and Open Telemetry.
1245
1257
Client libraries are required to send telemetry and distributed tracing information on every request. Telemetry information is vital to the effective operation of your service and should be a consideration from the outset of design and implementation efforts.
0 commit comments