use windows azure service bus, biztalk services, mobile services, and biztalk server to create...

27
Paolo Salvatori Principal Program Manager Windows Azure CAT [email protected] @babosbird Use Microsoft Azure technologies to build mobile services for the Enterprise

Upload: biztalk360

Post on 29-Nov-2014

2.243 views

Category:

Technology


1 download

DESCRIPTION

The Service Bus is part of Windows Azure and is designed to provide connectivity, queuing, and routing capabilities not only for the cloud applications but also for on-premises applications. Microsoft BizTalk Server enables organizations to connect and extend heterogeneous systems across the enterprise and with trading partners. Using both together enables a significant number of scenarios in which you can build secure, reliable and scalable hybrid solutions that span the cloud and on premises environments. Windows Azure BizTalk Services is a simple, powerful, and extensible cloud-based integration service that provides Business-to-Business (B2B) and Enterprise Application Integration (EAI) capabilities for delivering cloud and hybrid integration solutions. Windows Azure Mobile Services accelerates connected client application development by streamlining common backend tasks like structuring storage, authenticating users, and sending push notifications. In this session you will see how to integrate these technologies to build secure, reliable and scalable hybrid solutions that span the cloud and on premises environments.

TRANSCRIPT

Page 1: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Paolo SalvatoriPrincipal Program ManagerWindows Azure [email protected]@babosbird

Use Microsoft Azure technologies to build mobile services for the Enterprise

Page 2: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

• Introduction to Windows Azure Mobile Services

• Key Scenarios & Features• Creating Hybrid solutions with Windows

Azure Technologies• Summary & Useful Links• Q & A

Agenda

Page 3: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

why is mobile so important?

Page 4: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Enterprises want to manage internal mobile apps and consumer facing event- or product-specific mobile apps from the same portal as core LOB apps

Small Businesses require solutions that accelerate development time and decrease development costs.

Developers shouldn’t have to constantly reinvent the wheel and reproduce common backend functionality

Consumers expect a continuous experience across all devices

App DevelopmentChallenges

Page 5: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Windows Azure Mobile

Services accelerates connected

client application development by

streamlining common backend tasks like

structuring storage, authenticating

users, and sending push notifications.

Page 6: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Key Scenarios

Make your app engaging and dynamicPush notifications and Live Tiles is the premier way to engage your customers. Make your app engaging and dynamic using Mobile Services Push.

Rapid DevelopmentTime is money. Get your app up and running sooner when you use Mobile Services to configure a secure backend in less than five minutes.

Make your app socialWhether your customers use Google, Facebook, Twitter, or Microsoft Account, no matter what devices they run your app on, with Mobile Services you can makes your app social and personable fast.

Page 7: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Connected Apps

Windows Store iOS

Android

Windows Phone 8

iOS

Android

HTML 5/JS

Data in the Cloud

SQL Table Blob

User Authentication

Facebook Twitter Microsoft Google

Push Notifications

WNS & APNS GCMMPNS

SDKs

Server-Side

Scripts

Custom API

Scheduler

Windows Azure Mobile Services

Page 8: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

REST API

Operation Description

Login Gets the user ID for a supplied authentication token.

Query records Queries data in a table.Insert record Inserts a new record into a table.Update record Updates an existing record in a table.Delete record Deletes an existing record from a table.

 

Page 9: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Demo

Enterprise Scenarios: Integration with external applications via Service Bus, BizTalk Services and BizTalk Server

Page 10: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Mobile Services & SOAP Service Bus Relay Service

1. The HTML5/JS or Windows Store app sends a request to a custom API using the InvokeApi method of the MobileServiceClient class.

2. The custom API sends a request to ACS to acquire a security token.3. ACS issues and returns a security token. 4. The mobile service performs the following actions:

• Creates a SOAP envelope to invoke the WCF service. The Header contains a RelayAccessToken  returned by ACS.

• Uses the https module to send the SOAP request to the Relay Service.

5. The Relay Service forwards the request to WCF service. 6. The WCF service exposes a BasicHttpRelayBinding endpoint on

the Service Bus. It reads/writes/updates/deletes data from a local db.

7. The WCF service returns a response to the Relay Service. 8. The Relay Service forwards the message to the mobile service. 9. The custom API uses the xml2js Node.js module to change the

format of the response SOAP message from XML to JSON. The mobile service returns data in JSON format to the client app.

HTTPSOAP

HTML5/JS Windows Store App

HTTPREST

Page 11: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Get Access Token from ACSvar namespace = 'your-servicebus-namespace';var issuerName = 'owner';var issuerSecret = 'XXXXXXXXXXXXXXXXXXX=';var https = require('https');

function getAcsToken(response, callback) { var options = { host: namespace + '-sb.accesscontrol.windows.net', path: '/WRAPv0.9/', method: 'POST' }; var values = { wrap_name: issuerName, wrap_password: issuerSecret, wrap_scope: 'http://' + namespace + '.servicebus.windows.net/' }; var req = https.request(options, function (res) { res.on('data', function (data) { var token = qs.parse(data.toString('utf8')); if (res.statusCode == 200) { if (token.hasOwnProperty('wrap_access_token')) { callback(token.wrap_access_token); } else { response.send(400, "[getAcsToken]: ACS didn't return a valid token"); } } else { response.send(res.statusCode, util.format('[getAcsToken]: %s', data)); } }); }); req.write(qs.stringify(values)); req.end(); req.on('error', function (e) { response.send(400, util.format('[getAcsToken]: %j', e)); });}

Page 12: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Call SOAP Web Service (1/2)function addProduct(token, request, response) { if (request.body.hasOwnProperty('name') && request.body.hasOwnProperty('category') && request.body.hasOwnProperty('price')) { var product = '<product xmlns:i="http://www.w3.org/2001/XMLSchema-instance">' + '<productId>0</productId>' + '<name>' + request.body.name + '</name>' + '<category>' + request.body.category + '</category>' + '<price>' + request.body.price + '</price>' + '</product>' var base64token = new Buffer(token).toString('base64'); var tokenId = uuid.v1(); var body = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' + '<s:Header>' + '<RelayAccessToken xmlns="http://schemas.microsoft.com/netservices/2009/05/servicebus/connect">' + '<wsse:BinarySecurityToken wsu:Id="uuid:' + tokenId + '" ' + 'ValueType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0" ' + 'EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ' + 'xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" ' + 'xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' + base64token + '</wsse:BinarySecurityToken>' + '</RelayAccessToken>' + '</s:Header>' + '<s:Body>' + '<AddProduct xmlns="http://windowsazure.cat.microsoft.com/samples/servicebus">' + product + '</AddProduct>' + '</s:Body>' + '</s:Envelope>';var headers = { SOAPAction: 'addProduct', 'Content-Type': 'text/xml' };var options = { host: namespace + '.servicebus.windows.net', path: '/products/basichttp', headers: headers, method: ‘POST'};

Page 13: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Call SOAP Web Service (1/2) var req = https.request(options, function (res) {res.on('data', function (data) { var soap = data.toString('utf8'); if (res.statusCode == 200 || res.statusCode == 201 || res.statusCode == 202) { var xml2js = require('xml2js'); var parser = new xml2js.Parser(); parser.parseString(soap, function (error, json) { if (error) { response.send(400, '[addProduct]: An error occurred while parsing the response.'); } else { try { var product = json["s:Envelope"]["s:Body"]["AddProductResponse"]["product"]; response.send(200, product); } catch (ex) { response.send(400, '[addProduct]: An error occurred while processing the response.'); } } }); } else { response.send(400, '[addProduct]: An error occurred while invoking the downstream service.'); } }); }); req.write(body); req.end();}

Page 14: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Mobile Services & REST Service Bus Relay Service

1. The HTML5/JS site or Windows Store app sends a request to a custom API using the InvokeApi method

2. The custom API sends a request to ACS to acquire a security token.

3. ACS issues and returns a security token. 4. The mobile service uses the https module to send a request

to the Relay Service and specifies the wrap access token issues by ACS in the Authorization HTTP header

5. The Relay Service forwards the request to the WCF service. 6. The WCF service exposes a REST WebHttpRelayBinding

endpoint on the Service Bus. It reads/writes/updates/deletes data from a local db.

7. The WCF service returns a response to the Relay Service. 8. The Relay Service forwards the message to the mobile

service. The mobile service returns data in JSON format to the client app.

HTTPSOAP

HTML5/JS Windows Store App

HTTPREST

Page 15: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Call REST servicefunction addProduct(token, request, response) { if (request.body.hasOwnProperty('name') && request.body.hasOwnProperty('category') && request.body.hasOwnProperty('price')) { var product = { productId: 0, name: request.body.name, category: request.body.category, price: request.body.price }; var headers = { 'Authorization': token, 'Content-Type': 'application/json' }; var options = { host: namespace + '.servicebus.windows.net', path: '/products/webhttp/addproduct', headers: headers, method: 'POST' };

var req = https.request(options, function (res) { res.on('data', function (data) { var body = data.toString('utf8'); if (body) { console.log('[addProduct]: response body: ', body); } if (res.statusCode == 200 ||res.statusCode == 201 || res.statusCode == 202) { response.send(200, JSON.parse(body)); } else { response.send(400, '[addProduct]: An error occurred while invoking the downstream service.'); } }); }); req.write(JSON.stringify(product)); req.end(); req.on('error', function (e) { response.send(400, util.format('[addProduct]: %j', e)); }); } else { var message = "[addProduct]: The request body is not in JSON format or doesn't contain a well-formed product.in "; response.send(400, message); }}

Page 16: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Mobile Services & Windows Azure BizTalk Services

• The HTML5/JS site or Windows Store app sends a JSON request to a custom API.

• The custom API sends a request to ACS to acquire a security token.• ACS issues and returns a security token. • The mobile service performs the following actions:

• Extracts the wrap access token from the security token issued by ACS and assigns its value the Authorization HTTP request header.

• Creates a SOAP envelope to invoke the XML Request-Reply Bridge. • Uses the https module to send the SOAP envelope to the bridge.

• The bridge performs the following actions: • Validates the incoming request against the MobileSeviceRequest XML

schema• Promotes the location element in the incoming XML message. • Transform the message into the canonical format expected by the

calculator service. • Routes the request to EUROPE or US service based on the value of the

location prop.• The Relay Service forwards the message to the target service.• The service returns a response to the bridge via the Relay Service .• The bridge transforms and returns the response to the mobile service.• The custom API uses the xml2js Node.js module to change the format of the

response SOAP message from XML to JSON. • The mobile service returns data in JSON format to the client application.

HTML5/JS Windows Store App

HTTPSOAP

HTTPREST

Page 17: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Get Access Token from ACSvar bridgePath = '/default/CalculatorService';var bizTalkServiceScope = 'http://<your-biztalk-service-namespace>.biztalk.windows.net' + bridgePath;var https = require('https');var qs = require('querystring');function getAcsToken(response, callback) { var options = { host: ‘<your-service-bus-namespace>.accesscontrol.windows.net', path: '/WRAPv0.9/', method: 'POST' }; var values = { wrap_name: 'owner', wrap_password: 'XXXXXXXXXXXXXXXXXXXXXXXXXX=', wrap_scope: bizTalkServiceScope }; var req = https.request(options, function (res) { res.on('data', function (data) { var body = qs.parse(data.toString('utf8')); if (res.statusCode == 200) { if (body.hasOwnProperty('wrap_access_token')) { var header = 'WRAP access_token=\"' + body.wrap_access_token + '\"'; callback(header); } else { response.send(400, util.format("[getAcsToken]: ACS didn't return a valid token")); } } else { response.send(res.statusCode, util.format('[getAcsToken]: %s', data)); } }); }); req.write(qs.stringify(values)); req.end(); req.on('error', function (e) { response.send(400, util.format('[getAcsToken]: %j', e)); });}

Page 18: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Call XML Request-Response Bridgefunction callCalculatorBridge(token, request, response) { if (request.body.hasOwnProperty('location') && request.body.hasOwnProperty('operations') && Array.isArray(request.body.operations)) { var operations = request.body.operations; var body = '<?xml version="1.0" encoding="utf-8"?>' + '<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" ' + ... '<operations>'; var items = new Array(operations.length); var index = 0; for (var i = 0; i < operations.length; i++) { if (operations[i].hasOwnProperty('op') && operations[i].hasOwnProperty('op1') && operations[i].hasOwnProperty('op2')) { body = body + '<operation>' + '<op>' + operations[i].op + '</op>' + '<op1>' + operations[i].op1 + '</op1>' + '<op2>' + operations[i].op2 + '</op2>' + '</operation>'; items[index] = operations[i]; index++; } } body = body + '</operations></request></s:Body></s:Envelope>'; var headers = {'Accept':'application/soap+xml','Content-Type':'application/soap+xml', 'Authorization': token}; var options = {host: 'babonet.biztalk.windows.net', path: '/default/calculatorservice',headers: headers, method: 'POST', agent: agent }; var req = https.request(options, function (res) { ... }); }); req.write(body, 'utf8'); req.end(); req.on('error', function (e) { response.send(400, util.format('[callCalculatorBridge]: %j', e)); }); } else { response.send(400, "[callCalculatorBridge]: The request body is not in JSON format or doesn't contain all the necessary fields."); }}

Page 19: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Mobile Services & Windows Azure BizTalk Services

• The HTML5/JS site or Windows Store app or Windows Phone 8 sends a JSON request to a custom API.

• The custom API sends a request to ACS to acquire a security token.

• ACS issues and returns a security token. • The mobile service performs the following actions:

• Extracts the wrap access token from the security token issued by ACS and assigns its value the Authorization HTTP request header.

• Creates a SOAP envelope to invoke the XML Request-Reply Bridge.

• Uses the https module to send the SOAP envelope to the bridge.

• The bridge performs the following actions: • Validates the incoming request against the

MobileSeviceRequest XML schema• Promotes the location element in the incoming XML

message. • Transform the message into the canonical format expected

by the calculator service. • Routes the request to the BizTalk Adapter Service via SB

Relay.• The BizTalk Adapter Service accesses data using the SQL

Adapter.• The BizTalk Adapter Service returns a response to the bridge

via SB Relay.• The bridge transforms and returns the response to the mobile

service.• The custom API uses the xml2js Node.js module to change the

format of the response SOAP message from XML to JSON. • The mobile service returns data in JSON format to the client

application.

Page 20: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Web Site & Windows Azure BizTalk Services

• The HTML5/JS site or Windows Store app or Windows Phone 8 sends a JSON request to an ASP.NET Web API REST service.

• The custom API sends a request to ACS to acquire a security token.

• ACS issues and returns a security token. • The Web API service performs the following actions:

• Extracts the wrap access token from the security token issued by ACS and assigns its value the Authorization HTTP request header.

• Creates a SOAP envelope to invoke the XML Request-Reply Bridge.

• Sends the message to the BizTalk Service using POST method.

• The bridge performs the following actions: • Validates the incoming request against the

MobileSeviceRequest XML schema• Promotes the location element in the incoming XML message. • Transform the message into the canonical format expected by

the calculator service. • Routes the request to the BizTalk Adapter Service via SB

Relay.• The BizTalk Adapter Service accesses data using the SQL

Adapter.• The BizTalk Adapter Service returns a response to the bridge via

SB Relay.• The bridge transforms and returns the response to the Web API

service.• The Web API service returns data in JSON format to the client

application.

Page 21: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Mobile Services & BizTalk Server 2013

HTML5/JS Windows Store App Windows Phone 8Push Notification

Push Notification

AuthenticationProviders

authentication/authorization getUserName

1. The client app sends auth credentials to the MS. 2. The authentication provider validates the

credentials (username and password) and issues a security token.

3. The mobile service returns its access token to the client application. The user sends a new item to the MS.

4. The insert script for the TodoItem table handles the incoming call. The script calls the authentication provider using the request module to retrieve the user name from the user token.

5. The script sends a request to ACS to acquire a security token. The script calls BizTalk Server via a Relay Service to retrieve the user address.

6. The script inserts the new item in the TodoItem table.

7. The script reads the Channel URI of Windows Phone 8 and Windows Store apps from the Channel table.

8. The script sends Push Notifications. 9. The script uses the azure module to send a

notification to BizTalk Server via a Service Bus queue.

Page 22: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Send a XML message to Service Bus queuefunction sendMessageToServiceBus() { var azure = require('azure'); var serviceBusService = azure.createServiceBusService('<your-service-bus-namespace-name>', '<your-service-bus-namespace-key>'); var queueOptions = { EnableBatchedOperations: true, RequiresDuplicateDetection: true, DuplicateDetectionHistoryTimeWindow: 'PT8H' }; serviceBusService.createQueueIfNotExists('mobileservices/todoitem', queueOptions, function (error) { if (error) { console.error("An error occurred creating/accessing the Service Bus queue: ", error); } else { var builder = require('xmlbuilder'); var root = builder.create('todoItem', { 'version': '1.0', 'encoding': 'UTF-8' }); root.ele('userId', user.userId); root.ele('text', item.text); root.ele('complete', item.complete.toString()); var message = { body: root.end({ 'pretty': true, 'indent': ' ', 'newline': '\n' }), messageId: item.id, customProperties: { source: 'Mobile Services', author: 'Paolo Salvatori' } }; // Send the message to the queue serviceBusService.sendQueueMessage('mobileservices/todoitem', message, function (error) { if (!error) { console.log('Sent message: ' + message); } }); } });}

Page 23: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Related ContentArticles/CodeHow to integrate a Mobile Service with a SOAP Service Bus Relay Service

http://code.msdn.microsoft.com/windowsazure/How-to-integrate-a-Mobile-8780500c

How to integrate a Mobile Service with a REST Service Bus Relay Servicehttp://code.msdn.microsoft.com/windowsazure/How-to-integrate-a-Mobile-1ee6a5ea

How to integrate Mobile Services with Windows Azure BizTalk Serviceshttp://code.msdn.microsoft.com/windowsazure/How-to-integrate-Mobile-6718aaf2

How to integrate Mobile Services with BizTalk Server via Service Bushttp://code.msdn.microsoft.com/windowsazure/How-to-integrate-Mobiles-77b25d12

How to integrate Mobile Services with a LOB app via BizTalk Adapter Service

http://code.msdn.microsoft.com/windowsazure/How-to-integrate-Mobile-f2fca10d

How to send a large message to a Service Bus Relay Service using Streamed mode

http://code.msdn.microsoft.com/windowsazure/How-to-send-a-large-c36ab70e

Page 24: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Related Content

Articles/CodeWindows Azure Mobile Services

http://www.windowsazure.com/en-us/develop/mobile/

Tutorials and Resourceshttp://www.windowsazure.com/en-us/develop/mobile/resources-html/

Upload File to Windows Azure Blob Storage using Windows Azure Mobile Services

http://code.msdn.microsoft.com/Upload-File-to-Windows-c9169190

Getting user information on Azure Mobile Serviceshttp://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx

Troubleshooting authentication issues in Azure Mobile Serviceshttp://blogs.msdn.com/b/carlosfigueira/archive/2012/10/23/troubleshooting-authentication-issues-in-azure-mobile-services.aspx

Page 25: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Related Content

Articles/CodeHow to Use the Table Service from Node.js

http://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/table-services/

How to Use Service Bus Queueshttp://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/service-bus-queues/

How to Use Service Bus Topics/Subscriptionshttp://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/service-bus-topics/

How to Send Email Using SendGrid from Node.jshttp://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/sendgrid-email-service/

Page 26: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

Related Content

BlogsPaolo Salvatori Blog

http://blogs.msdn.com/b/paolos

Josh Twist Bloghttp://www.thejoyofcode.com/

Nick Harris Bloghttp://www.nickharris.net/

Carlos Figuerahttp://blogs.msdn.com/b/carlosfigueira/

Page 27: Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk Server to create hybrid solutions

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.