11# Microsoft Azure SDK for Rust
22
3- [ ![ docs] ( https://docs.rs/azure_sdk_for_rust/badge.svg )] ( https://docs.rs/azure_sdk_for_rust/0.12 .0/azure_sdk_for_rust )
3+ [ ![ docs] ( https://docs.rs/azure_sdk_for_rust/badge.svg )] ( https://docs.rs/azure_sdk_for_rust/0.20 .0/azure_sdk_for_rust )
44
55[ ![ legal] ( https://img.shields.io/github/license/mindflavor/AzureSDKForRust.svg )] ( LICENSE )
66
77[ ![ Build Status] ( https://travis-ci.org/MindFlavor/AzureSDKForRust.svg?branch=master )] ( https://travis-ci.org/MindFlavor/AzureSDKForRust ) [ ![ Coverage Status] ( https://coveralls.io/repos/MindFlavor/AzureSDKForRust/badge.svg?branch=master&service=github )] ( https://coveralls.io/github/MindFlavor/AzureSDKForRust?branch=master ) ![ stability-unstable] ( https://img.shields.io/badge/stability-unstable-yellow.svg )
88
99[ ![ Crate] ( https://img.shields.io/crates/v/azure_sdk_for_rust.svg )] ( https://crates.io/crates/azure_sdk_for_rust ) [ ![ cratedown] ( https://img.shields.io/crates/d/azure_sdk_for_rust.svg )] ( https://crates.io/crates/azure_sdk_for_rust ) [ ![ cratelastdown] ( https://img.shields.io/crates/dv/azure_sdk_for_rust.svg )] ( https://crates.io/crates/azure_sdk_for_rust )
1010
11- [ ![ tag] ( https://img.shields.io/github/tag/mindflavor/AzureSDKForRust.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/tree/0.12 .0 )
12- [ ![ release] ( https://img.shields.io/github/release/mindflavor/AzureSDKForRust.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/releases/tag/0.12 .0 )
13- [ ![ commitssince] ( https://img.shields.io/github/commits-since/mindflavor/AzureSDKForRust/0.12 .0.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/commits/master )
11+ [ ![ tag] ( https://img.shields.io/github/tag/mindflavor/AzureSDKForRust.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/tree/0.20 .0 )
12+ [ ![ release] ( https://img.shields.io/github/release/mindflavor/AzureSDKForRust.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/releases/tag/0.20 .0 )
13+ [ ![ commitssince] ( https://img.shields.io/github/commits-since/mindflavor/AzureSDKForRust/0.20 .0.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/commits/master )
1414
1515[ ![ GitHub contributors] ( https://img.shields.io/github/contributors/MindFlavor/AzureSDKForRust.svg )] ( https://github.com/MindFlavor/AzureSDKForRust/graphs/contributors )
1616
@@ -25,6 +25,19 @@ From version 0.12.0 the library switched from [hyper-tls](https://github.com/hyp
2525
2626> ** NOTE:** This repository is under heavy development and is likely to break over time. The current releases will probabily contain bugs. As usual open issues if you find any.
2727
28+ ## Upgrading from 0.12.0
29+
30+ Starting from version ` 0.20.0 ` the monolithic crate has been split in several smaller, more manageable, crates. This means you will have to update both your ` Cargo.toml ` and your ` use ` statements to use the new version. The crate's names are as follows:
31+
32+ * [ azure_sdk_core] ( azure_sdk_core )
33+ * [ azure_sdk_cosmos] ( azure_sdk_cosmos )
34+ * [ azure_sdk_service_bus] ( azure_sdk_service_bus )
35+ * [ azure_sdk_storage_blob] ( azure_sdk_storage_blob )
36+ * [ azure_sdk_storage_core] ( azure_sdk_storage_core )
37+ * [ azure_sdk_storage_table] ( azure_sdk_storage_table )
38+
39+ The names should be self-explanatory; the examples have been updated to use the new crate topology. In case of doubt please do not hesitate to open an issue. As for the functionality, the release ` 0.20.0 ` is equivalent to the ` 0.12.0 ` so you can migrate to the new crate topology without embedding extra bugs (hopefully! :wink : ).
40+
2841## Disclaimer
2942Although I am a Microsoft employee, this is not a Microsoft endorsed project. It's simply a pet project of mine: I love Rust (who doesn't? :smirk : ) and Microsoft Azure technologies so I thought to close the gap between them. It's also a good project for learning Rust. This library relies heavily on [ Hyper] ( https://github.com/hyperium/hyper ) . We use the latest Hyper code so this library is fully async with Futures and Tokio.
3043
@@ -34,25 +47,14 @@ You can find examples in the [```examples```](https://github.com/MindFlavor/Azur
3447### main.rs
3548
3649``` rust
37- extern crate azure_sdk_for_rust;
38-
39- extern crate chrono;
40- extern crate futures;
41- extern crate hyper;
42- extern crate hyper_tls;
43- extern crate tokio;
44- extern crate tokio_core;
45-
46- use std :: error :: Error ;
47-
48- use futures :: future :: * ;
49- use tokio_core :: reactor :: Core ;
50-
51- use azure_sdk_for_rust :: cosmos :: {AuthorizationToken , Client , TokenType };
52-
5350#[macro_use]
5451extern crate serde_derive;
55- use azure_sdk_for_rust :: cosmos;
52+ // Using the prelude module of the Cosmos crate makes easier to use the Rust Azure SDK for Cosmos
53+ // DB.
54+ use azure_sdk_cosmos :: prelude :: * ;
55+ use futures :: future :: * ;
56+ use std :: error :: Error ;
57+ use tokio_core :: reactor :: Core ;
5658
5759#[derive(Serialize , Deserialize , Debug )]
5860struct MySampleStruct <'a > {
@@ -62,14 +64,8 @@ struct MySampleStruct<'a> {
6264 a_timestamp : i64 ,
6365}
6466
65- // Following the official azure cosmos db tutorial: https://docs.microsoft.com/pt-br/azure/cosmos-db/sql-api-dotnetcore-get-started
66- // Master key is the Primary Key from Keys section in your CosmosDB screen
67- // Account is the first part of URI from Keys section, if your URI is https://test.documents.azure.com:443/ the account is test
68- // DATABASES are the base objects in your Data Explorer section
69- // COLLECTIONS are the objects inside the DATABASES
70-
71- const DATABASE : & 'static str = " azuresdktestdb" ;
72- const COLLECTION : & 'static str = " azuresdktc" ;
67+ const DATABASE : & str = " azuresdktestdb" ;
68+ const COLLECTION : & str = " azuresdktc" ;
7369
7470fn main () {
7571 code (). unwrap ();
@@ -85,13 +81,11 @@ fn main() {
8581// We will use multiple futures for this hoping to make the code clearer.
8682// There is no need to proceed this way in your code.
8783// You can go crazy with future combinators if you want to :)
88- fn code () -> Result <(), Box <Error >> {
84+ fn code () -> Result <(), Box <dyn Error >> {
8985 // Let's get Cosmos account and master key from env variables.
9086 // This helps automated testing.
91- let master_key =
92- std :: env :: var (" COSMOSDB_MASTER_KEY" ). expect (" Set env variable COSMOS_MASTER_KEY first!" );
93- let account =
94- std :: env :: var (" COSMOSDB_ACCOUNT" ). expect (" Set env variable COSMOS_ACCOUNT first!" );
87+ let master_key = std :: env :: var (" COSMOS_MASTER_KEY" ). expect (" Set env variable COSMOS_MASTER_KEY first!" );
88+ let account = std :: env :: var (" COSMOS_ACCOUNT" ). expect (" Set env variable COSMOS_ACCOUNT first!" );
9589
9690 // First, we create an authorization token. There are two types of tokens, master and resource
9791 // constrained. Please check the Azure documentation for details. You can change tokens
@@ -125,35 +119,35 @@ fn code() -> Result<(), Box<Error>> {
125119 // we will create it. The collection creation is more complex and
126120 // has many options (such as indexing and so on).
127121 let collection = {
128- let collections = core . run (client . list_collections (& DATABASE ))? ;
122+ let collections = core . run (client . list_collections (& database . id ))? ;
129123
130124 if let Some (collection ) = collections . into_iter (). find (| coll | coll . id == COLLECTION ) {
131125 collection
132126 } else {
133- let indexes = cosmos :: collection :: IncludedPathIndex {
134- kind : cosmos :: collection :: KeyKind :: Hash ,
135- data_type : cosmos :: collection :: DataType :: String ,
127+ let indexes = IncludedPathIndex {
128+ kind : KeyKind :: Hash ,
129+ data_type : DataType :: String ,
136130 precision : Some (3 ),
137131 };
138132
139- let ip = cosmos :: collection :: IncludedPath {
133+ let ip = IncludedPath {
140134 path : " /*" . to_owned (),
141135 indexes : vec! [indexes ],
142136 };
143137
144- let ip = cosmos :: collection :: IndexingPolicy {
138+ let ip = IndexingPolicy {
145139 automatic : true ,
146- indexing_mode : cosmos :: collection :: IndexingMode :: Consistent ,
140+ indexing_mode : IndexingMode :: Consistent ,
147141 included_paths : vec! [ip ],
148142 excluded_paths : vec! [],
149143 };
150144
151- let coll = cosmos :: collection :: Collection :: new (COLLECTION , ip );
145+ let coll = Collection :: new (COLLECTION , ip );
152146 // Notice here we specify the expected performance level.
153147 // Performance levels have price impact. Also, higher
154148 // performance levels force you to specify an indexing
155149 // strategy. Consult the documentation for more details.
156- core . run (client . create_collection (& DATABASE , 400 , & coll ))?
150+ core . run (client . create_collection (& database . id , 400 , & coll ))?
157151 }
158152 };
159153
@@ -173,15 +167,11 @@ fn code() -> Result<(), Box<Error>> {
173167 // Notice how easy it is! :)
174168 // The method create_document will return, upon success,
175169 // the document attributes.
176- let document_attributes = core . run (
177- client
178- . create_document (& DATABASE , & COLLECTION , & doc )
179- . execute (),
180- )? ;
170+ let document_attributes = core . run (client . create_document (& database . id, & collection . id, & doc ). execute ())? ;
181171 println! (" document_attributes == {:?}" , document_attributes );
182172
183173 // We will perform some cleanup. First we delete the collection...
184- core . run (client . delete_collection (DATABASE , & COLLECTION ))? ;
174+ core . run (client . delete_collection (DATABASE , COLLECTION ))? ;
185175 println! (" collection deleted" );
186176
187177 // And then we delete the database.
@@ -303,6 +293,10 @@ export AZURE_EVENT_HUB_NAME=<azure_event_hub_name>
303293export AZURE_POLICY_NAME=< azure_policy_name>
304294export AZURE_POLICY_KEY=< azure policy key>
305295
296+ cd azure_sdk_service_bus
297+ cargo test --features=test_e2e
298+
299+ cd ../azure_sdk_storage_blob
306300cargo test --features=test_e2e
307301```
308302
@@ -317,6 +311,10 @@ set AZURE_EVENT_HUB_NAME=<azure_event_hub_name>
317311set AZURE_POLICY_NAME=<azure_policy_name>
318312set AZURE_POLICY_KEY=<azure policy key>
319313
314+ cd azure_sdk_service_bus
315+ cargo test --features=test_e2e
316+
317+ cd ../azure_sdk_storage_blob
320318cargo test --features=test_e2e
321319```
322320
0 commit comments