MindFlavor / AzureSDKForRust

Microsoft Azure SDK for Rust
http://mindflavor.github.io/AzureSDKForRust
Apache License 2.0
160 stars 62 forks source link

Support SAS URL in addition to SAS Token. #123

Open bmc-msft opened 5 years ago

bmc-msft commented 5 years ago

In the Azure portal and Storage Explorer, when you generate a SAS token, you are given the option to use the generated SAS URL, which can include much of the details needed for the rest of the operations.

These are in the form:

https://a.blob.core.windows.net/b/c?d

This would simplify the use of Client::azure_sas() as well as provide some of the needed information when the SAS token is limited to a specific object, rather than container or storage account.

As an example, providing the SAS URL looks like this now:

let client = Client::azure_sas("a", "https://a.blob.core.windows.net/b/c?d");
let future client.get_blob().with_container_name("b").with_blob_name("c").finalize();

Where parsing that information out (of which, Url::Options is already being used to parse the token), it could look like this:

let client = Client::azure_sas_url("https://a.blob.core.windows.net/b/c?d");
let future = client.get_blob().finalize();

Supporting SAS URLs significantly improves the ergonomics of user supplied storage locations. As an example, the javascript library supports these:

bmc-msft commented 5 years ago

As SAS URLs can be fore the account, container, or blob, doing the parsing to identify the components provided in the URL would be needful.

Example, this would provide everything: https://a.blob.core.windows.net/b/c?d

Example, this would provide just the account, token, and container name: https://a.blob.core.windows.net/b?d

Example, this would provide just the account and token: https://a.blob.core.windows.net/?d