This repository was archived by the owner on Oct 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
azure_sdk_storage_table/examples Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ use azure_sdk_storage_core:: client:: Client ;
2
+ use azure_sdk_storage_table:: table:: TableService ;
3
+ use futures:: future:: * ;
4
+ use std:: error:: Error ;
5
+ use tokio_core:: reactor:: Core ;
6
+
7
+ fn main ( ) {
8
+ code ( ) . unwrap ( ) ;
9
+ }
10
+
11
+ // We run a separate method to use the elegant quotation mark operator.
12
+ // A series of unwrap(), unwrap() would have achieved the same result.
13
+ fn code ( ) -> Result < ( ) , Box < dyn Error > > {
14
+ // First we retrieve the account name and master key from environment variables.
15
+ let account = std:: env:: var ( "STORAGE_ACCOUNT" ) . expect ( "Set env variable STORAGE_ACCOUNT first!" ) ;
16
+ let master_key = std:: env:: var ( "STORAGE_MASTER_KEY" ) . expect ( "Set env variable STORAGE_MASTER_KEY first!" ) ;
17
+
18
+ let mut core = Core :: new ( ) ?;
19
+
20
+ let client = Client :: new ( & account, & master_key) ?;
21
+ let table_service = TableService :: new ( client) ;
22
+
23
+ let future = table_service. list_tables ( ) . and_then ( move |tables| {
24
+ println ! ( "Account {} has {} tables(s)" , account, tables. len( ) ) ;
25
+ for ref table in tables {
26
+ println ! ( "{}" , table) ;
27
+ }
28
+ Ok ( ( ) )
29
+ } ) ;
30
+
31
+ core. run ( future) ?;
32
+ Ok ( ( ) )
33
+ }
You can’t perform that action at this time.
0 commit comments