Из данной презентации Сергея Матюкевича, .NET-разработчика в Альторосе, вы узнаете:
1) основные принципы работы с Azure Mobile Services
2) достоинства/недостатки
3) как создать custom behavior, API и т.д.
Презентация была представлена на внутреннем .NET-баркэмпе компании.
1. Обзор MS Azure Mobile Services:
использование custom behavior, SDKs, API и т.д.
Матюкевич Сергей
.NET Developer в Altoros
www.altoros.com
2. Features
Simple and fast back-end development for mobile
apps
Easy scaling
SQL Server and MongoDB support
A variety of handy in-built features (e.g., single
sign-on with Active Directory, Facebook, Twitter
and other services, push notifications, etc.)
.NET and Node.js back-end support
Подробнее: azure.microsoft.com/en-us/services/mobile-services
6. Add some custom behavior
function insert(item, user, request) {
var todoItemTable = tables.getTable('TodoItem');
if (request.parameters.duplicateText === 'false') {
todoItemTable.where({
text: item.text,
complete: false
}).read({
success: insertItemIfNotComplete
});
} else {
request.execute();
}
function insertItemIfNotComplete(existingItems) {
if (existingItems.length > 0) {
request.respond(statusCodes.CONFLICT,
"Duplicate items are not allowed.");
} else {
// Insert the item as normal.
request.execute();
}
7. Use one of the provided SDKs
(JS in the example)
<script src='http://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.1.2.min.js'></script>
var MobileServiceClient = WindowsAzure.MobileServiceClient;
var client = new MobileServiceClient('AppUrl', 'AppKey');
var todoItemTable = client.getTable('todoitem');
var query = todoItemTable.where({
complete: false
}).read().done(function (results) {
alert(JSON.stringify(results));
}, function (err) {
alert("Error: " + err);
});
8. Observe actual requests to API
GET /tables/todoitem?$filter=(complete+eq+false) HTTP/1.1
SELECT *
FROM TodoItem
WHERE ISNULL(complete, 0) = 0
9. Use some additional features like
sorting, filtering, and pagination
query.where({
complete: false
})
.select('id', 'assignee')
.orderBy('assignee')
.take(10)
.read().done(function (results) {
alert(JSON.stringify(results));
}, function (err) {
alert("Error: " + err);
11. Authentication
In-built identity providers (Microsoft Account,
Facebook, Twitter, Google, Azure Active Directory)
A possibility to implement custom identity provider
A possibility to restrict access to the tables per
operation (Read, Insert, Update, Delete)
A possibility to work with a user identity in custom
scripts to implement more advanced authorization
logic