Microsoft Azure SDK for Rust
Introduction
Microsoft Azure expose its technologies via REST API. These APIs are easily consumable from any language (good) but are weakly typed. With this library and its related crate you can exploit the power of Microsoft Azure from Rust in a idiomatic way.
This crate relies heavily on the excellent crate called Hyper. As of this library version 0.4.1 all the methods are future-aware. That is, I'm using the latest Hyper code.
Rust, however, still requires you to Box every future returned by a method. The alternative is to use the impl Trait
feature which is nightly-only. Since I've used it everywhere this library will require a nightly Rust compiler until the impl Trait
makes its way to the stable channel. Also since I'm using an unstable feature these is a very good chance of this code to break in the future.
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.
Disclaimer
Although 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. We use the latest Hyper code so this library is fully async with Futures and Tokio.
Example
You can find examples in the examples
folder. Here is a sample however:
main.rs
extern crate azure_sdk_for_rust;
extern crate futures;
extern crate tokio_core;
extern crate tokio;
extern crate hyper;
extern crate hyper_tls;
extern crate chrono;
use Error;
use *;
use Core;
use ;
use Client;
extern crate serde_derive;
use cosmos;
const DATABASE: &'static str = "azuresdktestdb";
const COLLECTION: &'static str = "azuresdktc";
// This code will perform these tasks:
// 1. Find an Azure Cosmos DB called *DATABASE*. If it does not exist, create it.
// 2. Find an Azure Cosmos collection called *COLLECTION* in *DATABASE*. If it does not exist, create it.
// 3. Store an entry in collection *COLLECTION* of database *DATABASE*.
// 4. Delete everything.
//
// We will use multiple futures for this hoping to make the code clearer.
// There is no need to proceed this way in your code.
// You can go crazy with future combinators if you want to :)
State of the art
Right now the key framework is in place (authentication, enumerations, parsing and so on). If you want to contribute please do! Methods are added daily so please check the CHANGELOG.md for updates on the progress. Also note that the project is in early stages so the APIs are bound to change at any moment. I will strive to keep things steady but since I'm new to Rust I'm sure I'll have to correct some serious mistake before too long :smile:. I generally build for the latest nightly and leave to Travis to check the retrocompatibility.
Contributing
If you want to contribute please do! No formality required! :wink:. Please note that asking for a pull request you accept to yield your code as per Apache license, version 2.0.
Implemented methods
Storage Container
Method | URL |
---|---|
Create container | https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx |
List containers | https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx |
Delete container | https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx |
Storage blobs
Event Hubs
Method | URL |
---|---|
Send Event | https://msdn.microsoft.com/en-us/library/azure/dn790664.aspx |
Cosmos database
Database
Method | URL |
---|---|
Create database | https://docs.microsoft.com/en-us/rest/api/documentdb/create-a-database |
List database | https://docs.microsoft.com/en-us/rest/api/documentdb/list-databases |
Get database | https://docs.microsoft.com/en-us/rest/api/documentdb/get-a-database |
Delete database | https://docs.microsoft.com/en-us/rest/api/documentdb/delete-a-database1 |
Collection
Method | URL |
---|---|
Create collection | https://docs.microsoft.com/en-us/rest/api/documentdb/create-a-collection |
List collections | https://docs.microsoft.com/en-us/rest/api/documentdb/list-collections |
Get collection | https://docs.microsoft.com/en-us/rest/api/documentdb/get-a-collection |
Delete collection | https://docs.microsoft.com/en-us/rest/api/documentdb/delete-a-collection |
Replace collection | https://docs.microsoft.com/en-us/rest/api/documentdb/replace-a-collection |
Document
Method | URL |
---|---|
Create document | https://docs.microsoft.com/en-us/rest/api/documentdb/create-a-document |
List documents | https://docs.microsoft.com/en-us/rest/api/documentdb/list-documents |
Get document | https://docs.microsoft.com/en-us/rest/api/documentdb/get-a-document |
Azure tables
Azure tables entities can be manipulated in batches. The entities are serialized in JSON
.
Run E2E test (in progress)
License
This project is published under Apache license, version 2.0.