Skip to content

Commit 31a1a1a

Browse files
authored
Merge pull request #278 from JeffreyRichter/vNext
Simplify BYOS section
2 parents 264d98d + 453f958 commit 31a1a1a

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

azure/Guidelines.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -879,24 +879,26 @@ additional<br/>properties | | | Additional named or dynamic properties of th
879879

880880
:white_check_mark: **DO** retain the status monitor resource for some publicly documented period of time (at least 24 hours) after the operation completes.
881881

882-
### Bring your own Storage
883-
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.
884-
While Azure Managed Storage may be easier to get started with, as your service evolves and matures, BYOS will provide the most flexibility and implementation choices. Further, when designing your APIs, be cognizant of expressing storage concepts and how clients will access your data. For example, if you are working with blobs, then you should not expose the concept of folders, nor do they have extensions.
882+
### Bring your own Storage (BYOS)
883+
Many services need to store and retrieve data files. For this scenario, the service should not implement its own
884+
storage APIs and should instead leverage the existing Azure Storage service. When doing this, the customer
885+
"owns" the storage account and just tells your service to use it. Colloquially, we call this <i>Bring Your Own Storage</i> as the customer is bringing their storage account to another service. BYOS provides significant benefits to service implementors: security, performance, uptime, etc. And, of course, most Azure customers are already familiar with the Azure Storage service.
885886

886-
:white_check_mark: **DO** use Azure Bring Your Own Storage.
887+
While Azure Managed Storage may be easier to get started with, as your service evolves and matures, BYOS provides the most flexibility and implementation choices. Further, when designing your APIs, be cognizant of expressing storage concepts and how clients will access your data. For example, if you are working with blobs, then you should not expose the concept of folders.
887888

888-
:white_check_mark: **DO** use a blob prefix
889+
:white_check_mark: **DO** use the Bring Your Own Storage pattern
890+
891+
:white_check_mark: **DO** use a blob prefix for a logical folder (avoid terms such as ```directory```, ```folder```, or ```path```).
889892

890893
:no_entry: **DO NOT** require a fresh container per operation
891894

892-
#### Authentication
893-
How you secure and protect the data and files that your service uses will not only affect how consumable your API is, but also, how quickly you can evolve and adapt it. Implementing Role Based Access Control [RBAC](https://docs.microsoft.com/en-us/azure/role-based-access-control/overview) is the recommended approach.
894-
It is important to recognize that any roles defined in RBAC essentially become part of your API contract. For example, changing a role's permissions, e.g. restricting access, could effectively cause existing clients to break, as they may no longer have access to necessary resources.
895+
:white_check_mark: **DO** use managed identity and Role Based Access Control ([RBAC](https://docs.microsoft.com/en-us/azure/role-based-access-control/overview)) as the mechanism allowing customers to grant permission to their Storage account to your service.
895896

896897
:white_check_mark: **DO** Add RBAC roles for every service operation that requires accessing Storage scoped to the exact permissions.
897898

898899
:white_check_mark: **DO** Ensure that RBAC roles are backward compatible, and specifically, do not take away permissions from a role that would break the operation of the service. Any change of RBAC roles that results in a change of the service behavior is considered a breaking change.
899900

901+
900902
##### Handling 'downstream' errors
901903
It is not uncommon to rely on other services, e.g. storage, when implementing your service. Inevitably, the services you depend on will fail. In these situations, you can include the downstream error code and text in the inner-error of the response body. This provides a consistent pattern for handling errors in the services you depend upon.
902904

@@ -912,46 +914,46 @@ Designing an API for accessing a single file, depending on your scenario, is rel
912914

913915
:ballot_box_with_check: **YOU SHOULD** if using HTTP (not HTTPS) document to users that all information is sent over the wire in clear text.
914916

915-
:ballot_box_with_check: **YOU SHOULD** support managed identity using Azure Storage by default (if using Azure services).
917+
:white_check_mark: **DO** return an HTTP status code representing the result of your service operation's behavior.
918+
919+
:white_check_mark: **DO** include the Storage error information in the 'inner-error' section of an error response if the error was the result of an internal Storage operation failure. This helps the client determine the underlying cause of the error, e.g.: a missing storage object or insufficient permissions.
916920

917-
###### File Versioning
918-
Depending on your requirements, there are scenarios where users of your service will require a specific version of a file. For example, you may need to keep track of configuration changes over time to be able to rollback to a previous state. In these scenarios, you will need to provide a mechanism for accessing a specific version.
921+
:white_check_mark: **DO** allow the customer to specify a URL path to a single Storage object if your service requires access to a single file.
919922

920-
:white_check_mark: **DO** Enable the customer to provide an ETag to specify a specific version of a file.
921-
##### File Collections
922-
When your users need to work with multiple files, for example a document translation service, it will be important to provide them access to the collection, and its contents, in a consistent manner. Because there is no industry standard for working with containers, these guidelines will recommend that you leverage Azure Storage. Following the guidelines above, you also want to ensure that you don't expose file system constructs, e.g. folders, and instead use storage constructs, e.g. blob prefixes.
923+
:heavy_check_mark: **YOU MAY** allow the customer to provide a [last-modified](https://datatracker.ietf.org/doc/html/rfc7232#section-2.2) timestamp (in RFC1123 format) for read-only files. This allows the client to specify exactly which version of the files your service should use. When reading a file, your service passes this timestamp to Azure Storage using the [if-unmodified-since](https://datatracker.ietf.org/doc/html/rfc7232#section-3.4) request header. If the Storage operation fails with 412, the Storage object was modified and your service operation should return an appropriate 4xx status code and return the Storage error in your operation's 'inner-error' (see guideline above).
923924

924-
:white_check_mark: **DO** When using a Shared Access Signature (SAS), ensure this is assigned to the container and that the permissions apply to the content as well.
925+
:white_check_mark: **DO** allow the customer to specify a URL path to a logical folder (via prefix and delimiter) if your service requires access to multiple files (within this folder). For more information, see [List Blobs API](https://docs.microsoft.com/en-us/rest/api/storageservices/list-blobs)
925926

926-
:white_check_mark: **DO** When using managed identity, ensure the customer has given the proper permissions to access the file container to the service.
927+
:heavy_check_mark: **YOU MAY** offer an ```extensions``` field representing an array of strings indicating file extensions of desired blobs within the logical folder.
927928

928-
A common pattern when working with multiple files is for your service to receive requests that contain the location(s) of files to process, e.g. "input" and a location(s) to place the any files that result from processing, e.g. "output." (Note: the terms "input" and "output" are just examples and terms more relevant to the service domain are more appropriate.)
929+
A common pattern when working with multiple files is for your service to receive requests that contain the location(s) of files to process ("input") and a location(s) to place any files that result from processing ("output"). Note: the terms "input" and "output" are just examples; use terms more appropriate to your service's domain.
929930

930-
For example, in a request payload may look similar to the following:
931+
For example, a service's request body to configure BYOS may look like this:
931932

932933
```json
933934
{
934-
"input":{
935+
"input":{
935936
"location": "https://mycompany.blob.core.windows.net/documents/english/?<sas token>",
937+
"delimiter": "/",
938+
"extensions" : [ ".bmp", ".jpg", ".tif", ".png" ],
939+
"lastModified": "Wed, 21 Oct 2015 07:28:00 GMT"
940+
},
941+
"output":{
942+
"location": "https://mycompany.blob.core.windows.net/documents/spanish/?<sas token>",
936943
"delimiter":"/"
937-
},
938-
"output":{
939-
"location": "https://mycompany.blob.core.windows.net/documents/spanglish/?<sas token>",
940-
"delimiter":"/"
941-
}
944+
}
942945
}
943946
```
944-
Note: How the service gets the request body is outside the purview of these guidelines.
945947

946-
Depending on the requirements of the service, there can be any number of "input" and "output" sections, including none. However, for each of the "input" sections the following apply:
948+
Depending on the requirements of the service, there can be any number of "input" and "output" sections, including none.
947949

948-
:white_check_mark: **DO** include a JSON object that has string values for "location" and "delimiter."
950+
:white_check_mark: **DO** include a JSON object that has string values for "location" and "delimiter". For "location", the customer must pass a URL to a blob prefix which represents a directory. For "delimiter", the customer must specify the delimiter character they desire to use in the location URL; typically "/" or "\".
949951

950-
:white_check_mark: **DO** use a URL to a blob prefix with a container scoped SAS on the end with a minimum of `listing` and `read` permissions.
952+
:heavy_check_mark: **YOU MAY** support the "lastModified" field for input directories (see guideline above).
951953

952-
For each of the "output" sections the following apply:
954+
:white_check_mark: **DO** support a "location" URL with a container-scoped SAS that has a minimum of `listing` and `read` permissions for input directories.
953955

954-
:white_check_mark: **DO** use a URL to a blob prefix with a container scoped SAS on the end with a minimum of `write` permissions
956+
:white_check_mark: **DO** support a "location" URL with a container-scoped SAS that has a minimum of `write` permissions for output directories.
955957

956958
### Conditional Requests
957959
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.

0 commit comments

Comments
 (0)