Windows Azure Mobile Services from the ground up
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Merrigan, Niall
This session is geared at giving a comprehensive overview of Windows Azure Mobile Services and how you can use it in your apps. We will look quickly at the services before diving in an building an application that uses it.
 All right, let's see if it's working. Woo, we have sound. Fantastic. Right, there's a lot of people here. You actually found your way to Room 6. It was kind of a little maze. It's like a whole way to work out. If you're smart enough to get up here, you can be smart enough to leave if you want now. It's okay. This is Windows Azure Mobile Services. So if you're not ready for this talk or this is not what you're expecting, run. I'm trying to get people out, I swear. My name is Niall Merrigan and I work with Capgemini Norway. And this is actually going to be Azure Mobile Services because Microsoft decided to drop Windows from their Azure branding in a masterful move because everyone associates Windows with Microsoft and Microsoft with not running anything. But Azure actually runs quite a lot of other stuff other than Windows, so they've decided to, that's why they dropped it. It just means that all my slides are now a bit out of date. But if you've got Twitter and the internet and stuff like that, you can tweet me at nmerrigan and use the official NDC asl hashtag. There is a rating system and feedback system for speakers. As a speaker, I'm very narcissistic. I do love when someone tells me I'm good. I don't like when people tell me I'm bad. But I do appreciate that I may not hit all your buttons on the one day. So if there's something wrong, please tell us as speakers in general what is wrong. Because if you don't, it's like sending in, there is a bug. And I will reply back, there is a solution. And you will go, for what? And I'll say, for what you told me was wrong. And they will go, okay. So please, it's green fur, I like you yellow fur, I thought you were okay. And red, I'm not what don't want to be your friend. So it's very simple. If you're colorblind, just pick something up and throw it in. I'm Irish and I live in Ireland, or live in Norway actually. But these are actual Irish road signs. We advise you not to go with the speeding limit. For our international audience, people running at home and stuff like that and whatever. In Norway, the speed limit is about 80. And this scares a lot of Norwegian drivers. Because it's on the wrong side of the road and going up a cliff and you can fall off. However, Norway does like you to enforce the speed limit. So they just put tanks beside their photo boxes. I'm sorry, sir, you're getting two points in your car. Done. I work with Capgemini Norway in Stavanger. I am the head of custom software development there. I am an ASP.Net MVP, ASP insider, member of many developer advisory councils, general, shouty person. And today this is going to be about Azure Mobile Services. Now, back in the old days, when most of us were small and didn't know what a computer was, this was a database. This was our computer. And people generally, if they worked in one language, stayed in one language. If they worked in one technology, they stayed in one technology. Hi, I'm a VB developer. I write forms and line of business applications. Hi, I'm a Silverlight developer. I'm extinct. Hi, I'm a Cobalt developer. Sorry. I try to shove that in. Hi, I'm a Cobalt developer. I'm old. I don't do anything else. That's all I did. I very much focused on one technology, one language, nothing else. Now, we are all multi-platform. We're all about multiple different devices, multiple different technologies. If I asked any developer here, most of you would say, I know one language. I can probably do SQL. I'm learning two others as I'm going along. I'm working on.NET. I'm working with Linux. I'm working with Mac. I work with many different application technologies and platforms. But something that always remains in the background is the very humble database. It is, for a lot of people, it's where they begin their development process. It's a bad way to begin your development process if you begin with your database. But if you want to now share your data across multiple applications, which is a given in today's society, the idea that I would actually have to pick up something off one computer, and carry it to another device or something else, and load it up there is like incomprehensible. How many of you, if I said, sorry, do you want a copy of that code? Okay, will you come over to my computer, put in your USB stick, take it off, copy it over to your other device, and you're like, but why can't you just share it online, or why can't you just share it somewhere else? This idea of me having to physically move from a device to get the data is gone. The problem is, if you have to share all this data, how do you scale up? And how do you share all this data? Do you build your own data center? Do you make your database accessible to all the world? Or do you say, well, you know what, I can deploy a back end in the cloud, or I can just make a back end available? And this is what Azure Mobile Services is. It's your back end in the cloud. This is the product slide for this, and it says, you know, it hasn't been updated yet, but it's all about the data. You can store data in the cloud that can be shared across multiple devices. It also gives you push notifications. Now, notifications have become the de facto way of telling people or something you have to do with your application. We don't expect customers to actually open up our app, refresh to see if something happened, and then close the app. Customers like to be notified. Hi, you've got something you need to look at. Please look at it. Okay, we're gone beyond the idea of, I'll just go check my mail to see if I have mail. It's like, I expect a notification, I expect a buzz, I expect something to tell me that there's something for me to look at. Notifications are a standard now that you have to use in any mobile device. And now, for example, in other applications such as Windows 8, you have push notifications based on the desktop. We've seen it in browser for a long time, but now it's becoming in the application on the desktop as well. We now also think of authorization and authentication. Do you like remembering passwords and usernames? How many of you do? Anyone's? No? No one likes to remember using it. How many of you say, okay, sign up with Facebook or Google or Hotmail or whatever, and go, okay, great, click the button, done. One less thing I have to remember. Sorry, is that something I like doing? I do, sorry. Troy Hunt is here. He's a security guy, so if you're going to see his talk, he'll have a lot more of these fun questions. You've got server logic. We've gone beyond the idea of putting code on the front end that cannot be shared, and any time I have to do an update, I have to put an update to my application. We had for a long time, end tier applications where business logic stayed in the middle tier and data logic stayed in the bottom tier, and then you had front end just visualization. The exact same thing happens here. I want to store stuff that is common to all my devices and all my platforms in the one place. If I need to change it, I update it once. I don't need to update my application. Why do I want to do that? You've diagnostics, you've logging and scale. Right. I think we should start and show you how it works. We'll just start with a little demo. This is how I think these demos work. Let's do it. Welcome to the Azure portal. How many of you have seen the Azure portal? Everyone? Actually, first off, question. How many of you know what the cloud is? How many of you don't know what the cloud is? Good. Because I would say if you want to see the cloud, just look outside. It's wet. If you want to create, it's very simple, login with your LiveID, create a new, very simple mobile service, click create. We are going to create a URL which I'm going to call ndcauslowv2. I have a v1 just in case everything goes tits up on this because it did before. Use a new database. You get 20 megs free. Database all exists for Azure. Okay, using existing database. West US, I think I'll go for North Europe. You can actually use either JavaScript or.NET preview. Personally, I prefer the JavaScript version. The.NET is kind of web API stuff I'm built in. I don't know. I think when I'm doing mobile services, because it started off in JavaScript, it's just a bit more easy and it kind of sits that fluid way of working. I'm thinking that's what we should be using. I'm just going to just do... You must follow by a SQL password. Okay. We might just use any creating a SQL instance just in place. It might be just easier. ndb, configure server, North Europe. Now... And we click OK and we provision. So we wait a little bit longer. Following mobile services is not created. Database percentages are incorrect because firewalls are... Fantastic. Right, we're going with the one that I've created before, just in case. I honestly think that this has the demo gods of going, we will smite you. Smite you hard. I didn't say everyone starts with a hello world. I know I'm sorry. I didn't start with a hello world. All right, let's do this. And we'll bring up Visual Studio and I'll have my ndc-osl app. Okay. You can actually download an existing create new store app and just create... And just download this. And it will download a very sample app which we're going to use because it's nice and simple, open folder. One thing is if you download it, remember to unblock it because otherwise it will tell you you have to do that for everything. And it becomes quite annoying. Now we wait 15 hours for Visual Studio to load. Woohoo! It decided it would wake up today. I spoke too soon. I spoke too soon. Oh, God, come on. Hello? There we go. ndc-osl unavailable. Why could you not... That's probably because I'm reading this. We'll go into Server Explorer and inside here we can see in the tooling, I can see the mobile services that I have existing already. Now it's going to tell me I need to put in my password. Or I hope not, maybe not. I can see that I have an ndc-osl application written here. If I go back to my mobile services, as you can see it maps up to the two ones I have here. It's very simple to see all this. In ndc-osl, this is my dashboard. And it shows me as my mobile service what's actually happening. I've got a mobile service URL. It's running on HTTPS ndc-osl azuremobile.net. And I've got a database against ndc-osl db. I can see my data. I've got an API, custom API. I've got a scheduler, push, identity, logs, etc. What I'm going to do here, if I can see if this will work for me, we are just going to, I just have to rebuild this quickly. Actually we'll just press F5, it will be fine. If we press F5, and we wait, wait some more. Activation requests this error because the screen resolution is before. This is just fun. Screen resolution. It's 1280 by 720. Alright. Turn it to 11. Okay. Can everyone still see the screen? We're all good. Excellent. I bet you it's, no, we're okay. Registration successful. This is for push notifications. So when I insert it to do item, I click save. It should save this out. Okay. No reference exception. I'm sorry. I know it's like, sorry. I'm not having a good day today, am I? Alright, one second. Yes. The problem with the screens as well. It's like an etch-a-sketch. The problem with screens, let me just... Sorry, the joke was it's like an etch-a-sketch up here, so they're just going to flash the screens. Are we still good? No? We're not good? Alright, let's do a screen resolution down again. 1336 by 768. Apply changes. Is that all there? Alright. Let's see what's going on. Okay, we'd have to go back and see what actually the mobile service is doing when we look at our database in order to do item in our script. So we have an sent to script, and we'll do that. Okay. Refresh to do items. Let's just see what's going on. Refresh to do items. So if we go at five, it says invalid in there, so that'll be fine. But I'm going to open up the... Close this. Close that. We'll bring up the other one. And see if that'll work for me. Oh, the demo gods, they are fun. So while I'm burning here on stage... Yeah. Ha ha ha. Oh, there's always one funny Englishman in the back, isn't there? So if we go back to... Where's my v2 vision of that? Alright. At least my son is still smiling. At least my son is still smiling. That's right. That's... Distract all. Okay. Let's see if this will work. Close that. I'm sorry about this. This is always the mobile services talk. It works fine. It works on my machine, TM. I should actually just record this the whole thing and just say it actually does work. Well, while I'm here, we'll talk about it a bit more. In our side art to do item here on our table, we have a database that actually supports dynamic data. So what you can do is it has a dynamic schema enabled. This here means that as I build my application, you don't actually have to define what the table contains. I can actually say, please just use whatever object I'm sending in and build the schema accordingly on the database. So for example, say I have my to-do item here. If it will show me, let's see. Excellent. If we go back to main page, yes. We have a to-do item here, which has got ID, text, and complete. It's got JSON property. Should pick it up. Come on. And as we use this, and I'd say actually what's happening here is it just needs to get the package manager, tools. You get package manager and restore. Oops, sorry. Tools. You get package manager, restore these. So what will happen is that it will build. We should be just closing this. I'm finished. Great. Done. Now, have we got this? Can it resolve symbol? Oh, fantastic. So what it will do is it will put in the ID, text, and complete. If we go back to our mobile services here in... Did it bring up V2? Mobile services? Oh, yeah, because it didn't create the NDC also. So there we go. In our data, when I create a to-do item, it actually generates in the columns. It'll show me that it will generate the text, and complete an ID parts by actually adding those in. So... Why is this not picking up? Yeah, I'll try to build. Just to make sure for build. It's all started. Should pick it up fairly quickly. Build succeeded. Lovely. We're still giving... There we go. Thank God. Something actually works today. So if we look here, as it creates... When it creates the sample item, you actually create a new mobile services collection. It creates against the to-do item table, which just gets a get table to-do item. So it maps up against the get table. It will then says, I want to wait, insert async to-do item, and then just click add. It sends that up to the browser, and what are up to the mobile service? The mobile service will receive that for the insert command, and say, okay, what do I want to do with this request? I want to do a database. Right. I've got a number of different properties I don't recognize, but they're JSON serialized, and so I can... Because I've got dynamic schema enabled, I will just expand my schemas to actually match those object types. And that's all it has to do. So if I press F5, this should actually connect up to the other one. If we're working. See, there we go. We've got to refresh our data so far, so good. Sample item, insert. If we click save. Okay, so it just sends me back a push notification, because I've enabled it for push, and down here, sample item is inserted. Now, if we were to change that actual command to insert a new item into-do, it would actually expand the table, and we'll do that in a minute when we're going to do enable authentication. This is a very simple to-do item, but it shows you that I can save data up to the cloud and send it back. If I then put it into, for example, a mobile device, and I connect up to the exact same table, that device will have the same data, because it'll have the application key. If I go over to the server explorer here, and back in, I can... If I go into mobile services... A bit more, and I go to ANDC Oslo. We have our to-do item, which I can expand here, and I can actually see that on the insert, I can see the actual code that I'm writing against it. Now, this particular piece of code, it says, I want... When you insert, I want to send a response that I've inserted, but I also then want to send a notification, which uses notification hubs to push a notification back to all connected clients, and I'll explain that in a second. Now, if I want to add authentication, to do this, I would actually have to go into Facebook... Like, for example, if I want to add Facebook authentication, if we go back and explain a little bit about this. On Facebook authentication, you need to set up a developer account on Facebook. So that goes to developers.facebook.com, register yourself as a developer, and then you will be given this effectable dashboard for here. Very simple. I've created a demo account here. I create apps, create a new app, and this will come up with a display name, and you have to use a unique identifier here. Just note, it has to be lowercase for this, and then just choose a category and create the application. Once the application has been created like here, you then add a new platform for it. So that goes into settings, click Add a Platform, put in your site URL to your mobile device, or your mobile services, go back... Once you have that, into dashboard again, you go back and forth a little bit, I'd love this to be a bit simpler, copy out the app ID and the app secrets, go into mobile services... Hello, mobile services, yes, thank you. And we go into identity. And here, I can put in my different authentication schemes. So I have my app ID and my app secret. You can add Twitter. The thing with Twitter is that if you're doing this against local hosted, it will fail. So it's a valid, actual account that will do it. What I recommend if you're trying to test locally against with Twitter authentication against mobile services is instead of using local host, use a domain name that is just you have in your host file. So it will just map like example.com, and you say example.com. Yes, you can copy the key and I will look at it in a minute. It's fine. Sorry, the security guy here is just making jokes. It's not funny. It's bad enough up here as it is. So with Google and also with the Windows Azure Active Directory, and you have the Microsoft Live ID if you wish to use that. So once that's done, to enable security on your application, you click on permissions. And right now, it says the insert permission is anyone with the application key. So if I've got the application key to this application, you can use it. A word of note, the application key here is kind of sounds like it's a security token. If you're using authenticated login, if you just want to use login, use your mobile services to do your login, or OAuth login, the application key is actually not required. So because the actual JavaScript involved in this doesn't actually respect the authentication key. So any application can use your mobile service to OAuth. Now, it's, well, it's just, it's no big deal, but it means that you'll end up with a whole lot of service calls, and it could, you end up with possibly an idle service attack, whatever. Yeah, it's one of those things that I kind of found a bit weird that it didn't allow you to do that. So with the read permission, I'm just going to change it to only authenticated users, so it'll actually force the application to be authenticated at the start. Now for the application, it will be, to do the insert, you will need to have an authenticated token. We click wait for permissions. Good chance to get a glass of water. Have there been any questions so far? Anything at all? This is kind of weird. It's a real long, yes, sir? If you're more than one developer working on mobile services, how can you connect? If you're more than one developer working on mobile application services, how can you connect as in? So to this interface, I want to share with somebody else. So more than one developer or a team? Yes, and you want to use the actual, not this interface, like for example, you can use Visual Studio if you wish, but the thing is if it's a shared account, it'll have to be like a company account, which would mean that when you connect up here and use server explorer, and you say connect to Azure, you connect to Windows Azure, you actually, I'm currently selling this as my actual live account, but if I had an actual corporate account or something that was shared, you could actually use that in that case. Yeah, it's a cost issue, of course, but the thing is if you have a corporate account, in other words, this can all be server free, but say for example, you have a shared email address, mycompanyatlive.com or outlook.com, and say 20 developers have the password for it, they can all connect. It's not going to say that it has to be just one developer. In other words, I can have this running on four machines side by side, and it's not going to worry that, but you'll have concurrency problems if for example, someone changes something and it's code. It does support Git on this, so if you want to do actual changes and push back and forth, you can actually do that instead, and actually develop locally, push up to Azure and it'll work. So good question to answer is you have to have a shared email address that people will use. So to go back to our authentication, we should have now been authenticated. We've done, all right, excellent. So if I go into NDC also again, and I go back to my solution and main page. To actually authenticate, I need to insert my snippet, which is add a mobile service user to tell it that I want to have something that I can store the user credentials against and authenticate async. So I added a new function called authenticate async. And what this does is you see here, it says, await app.mobileservice.loginasync, mobile service authentication provider.facebook. So it will use.facebook. And if you, sorry,.facebook, it will use Facebook. So you have the option here of.facebook, Twitter, Microsoft account, and Windows Azure Active Directory. So we'll go back to Facebook. Excellent. And then to do that, we will have to tell it that on the, when the, where is it going down here? Back down here, refresh to do items on navigator two. It will be await authenticate async. And that will give an error because I need to put override async void. Now, press F5. We pray to the demo gods a little bit. Again. We hey. So it will come up with my connecting to service. Come on. There it is. As you notice, I'm using a very nice effective hidden domain thing called opaque. I actually really love this domain name opaque for those who actually speak English. It's quite funny, but those who don't, it's going to, huh? And I'll keep me logged in. I'll log in. Now you're logged in as Facebook user X. So it will now authenticate, it's now I've actually authenticated against my mobile service in what can be considered a couple of different clicks and running around. But that's it done. There are the easy bits. What we're going to talk a little bit more about now, if we go to Homer, we have our hammer time, active directory. We're going to talk a bit more about push notifications. Push notifications have come a hell of a long way. Right now you have Windows notification services, Windows phone notification services, Google Cloud messaging, Apple push notification services. And if you want to push to all different devices, you kind of have to kind of know how to send different posts and tiles to those particular devices. It seems like a lot of work. As a developer, I like stuff being easy. I like stuff being wrapped up a little bit that I can just say, make it work. I'm happy. That is where notification hubs come in. They are now in preview right now, but what they allow you to do is, hi, I want to send a message to everybody. Great. Who do you want to send it to? Well, all connected devices. You fix? It goes, I fix and just sends it out. It'll do a simple push notification to all devices that, regardless of device type or push notification service you need, it will just send. However, you can actually override it and say, okay, I want you to, for Windows notification services, I want you to send this type of posts and tile to it. No problem. I can do that. So we want to show you how that actually works. When you, to enable push notifications, normally what you will do is you'll right click on your application up here and just go to, where's it at? And you have a push notification and it will enable push notifications on your application. It takes a couple of minutes, but what will happen? It will ask you to register a namespace and an actual application name. So when you go into Twitter, go away, maybe go away, sorry, we'll bring this back up, you have a dev center for Windows. And when you log into this, keep me signed in, this will register your application against the dev center and it'll give you an application name. So for example, here, I have NDC Oslo. When I go to click on edit this, this will show me the different, this does it automatically for you. As enabling push notifications gives you, as far as number five, this piece done, it gives you your app name, reserves it, and then says it enables push notification services on your application. So it sends this client application secret back to you. When you go into your live services site here, again, this is the thing, it kind of wraps, enabling push notifications on mobile services wraps this up a little bit easier for you so you don't have to worry as much about doing all this stuff. Before, it was a manual process of sign up to the dev center, sign up to live services, this just enables it. But it gives you your application identity, your client ID, and your client secret. And these are all built back into the push notification service here. I'm going to show this. It automatically pre-populates those back into your application. But this is a subset of the Azure service bus. So when we go into the NDC Oslo hub, I can see my notification hub here, which is directly linked back to my mobile service. So that's what it provisions. It provisions an Azure service bus, which provisions internally in that, an actual notification hub. This allows you to send your push notifications to any connected device. What happens, how does your device actually receive notifications? It simply says, when I connect to your service, I'm going to register a channel URI. Great. And then our application holds that, and we'll use that for sending information back. You do this every time you actually register your device against your mobile service. So in our application, I'm going to take out my await here, because I really don't want to have to log in every five seconds. And I'm going to go into app.sammal. And I'm going to enable push notifications. I'll just add it here. So if I add push notifications, it does this, sign up windows, sign into windows store. And we have to go here. Yes, I don't know my own passwords for stuff anymore. Text it, okay. What could possibly go wrong with two-factor authentication? I feel like it's like the guy who has to open all the locks and you hear, ch-ch-ch-ch. Submit. Yay! So I've got NDC Oslo here, and it'll do that and click next. It'll look it up to a different subscription, which I already have. And I'll say NDC Oslo, next. Finish. Temptons to all windows Azure and mobile services. This takes a little bit of time. Okay, any of the push notifications services. Done. And done. So that's it done. We have our function set up that will notify all users and send an SMS. Excellent. Fantastic. Okay, so that's enabling push notifications on the server. Now we have to enable it in our application. So that's quite simple. Go in here. And we set up a new function. Thanks. And do micro snippets and initialize async down here. Yes, there we go. I forgot how to do this before, so love mom, thank you mom. Package manager is off. Yeah, there we go. It should have just done it already. And just paste. And then you can't solve. Paste. Hello. Install package. Come on. There we go. Remember when I said this thing is reliable. For all definitions. Messaging. Dodd managed. Oh, great. Fine, fine, fine, fine. It's just not funny. Oh, no, it is. Trust me, it's hilarious. It's hilarious, isn't it? All right, fine, fine, fine, fine. Why are we not doing this? Now you do that. And so in the application app, okay, yes. Create a new class notification app. No, I want to install the package. Install package. Microsoft. Azure. Windows Azure. No, not activities. Azure.Messaging.Managed. Why is it not giving me this? Yeah, I thought so. But that's why it just says install. It should install the package for me. So install this. Oh, I love you. What the hell? Yeah, I'm going to just search for it and we'll find out. And then we get a package manager. Don't need messaging. Messaging.Managed.Installed. There we go. Yes, I accept. Was that so hard? Oh, thank God. I love it. So we need to init then in, and I just removed this. I'm going to say init notifications async. Okay, f5 that. Messaging was not handled in user code. What the hell? Oh, yeah, that's because I forgot to end up with the endpoints. I know that would help. Well done, now. Okay, so that explains my next point, what you actually should do when you want to set this up. You manage the connection information. So the hub is called entity Oslo hub, and we want to use that here. And then we want to listen endpoint, which is just going to be here. And do that and put that in over here. I think it'll just, I think it's, yeah, I probably just, oh yeah, I've got extra codes there. Thank you. I'll go back here to this. All right, f5 this now. This is actually a great way to show you how not to develop. Don't ever come up and try and do live coding. Error loading items. Access is denied. Of course access denied because I forgot to take off the identity. So this is the really how you do the development environments kind of thing. It's like it actually shows you how to debug. So, yeah, that's how most of us do it as well. Yeah, that worked. Did any of you see Anthony's talk on solid for CSS? He was talking about spaghetti code in JavaScript. And I was thinking of saying, well, mostly spaghetti code in JavaScript happens because it works. Don't touch it. We're not going to, I don't know what actually why it works now, but it does work. And I don't want to stop permissions. So we'll just take that from any of the application key and any of the application key and click save. All right, so 20 minutes. We're fine. I'm going to go on and talk about disaster recovery, but it'll be kind of interesting because it's. Yes, go on, recover. Yes, registration successful. So when I send this information here, come on. Save. It should send me a notification. So there it goes. Now, that is a very simple notification. What I've done here is when it inserts, I have changed the code on the insert script to say the following, send notifications. It uses Azure require. So this is no JS and just as require Azure. You say, not create notification hub service. I've put in my endpoints that I've required the exact same thing. The hub and the endpoint and then said, just send WNS, send toast text to do this. Yeah, that's okay. We can, but we can actually use the custom API to test this as well in we have logs or is it no, it's in configure, I think. I'll show you in a sec. The where's it API. I've got a notify all users here, which will allow me to do a test notification if I want and then pushes and that'll allow you to if you run it, you'll actually send a notification to it. But to test it, what you actually can do is go into your hub and you're going to notification hubs. And you can click debug and you can do a random broadcast and you can send it to, for example, windows. And I can select notification type, just a tile and it'll give me some test message here. Or I can say I just do that and it'll just click send. Do you want to, yes. So it should actually broadcast to this device here. I hope all random devices may not. Yes. So let's try and do a send and send test message. Send. Send to us notification. And probably now what will happen is I'll get about four notifications in one go because notifications are best effort. They're not actually fully reliable, which is a bit of annoying thing. But if I want to do random broadcast, send a tag, it'll just send it down. What push notifications you can do further on is if we go to our back to our mobile service again. And go into our API. We can, for example, send a notification hubs here to this. Now if I bring up my notification hubs here. See if I've got this. Hello from mobile services. Scheduled up. Yes, I have a sample notification. If I go into my scheduler, I've got a sample push set up here in the script. And what this uses is a more advanced version of the hub. It's still the same hub, but it allows me to send, for example, here, send toast image in tech 01. So it'll actually allow me to send a run once. And I get a hello for NDC also, complete with badge, et cetera, and the whole lot. So I can actually send to specific. This will use the Microsoft or Windows notification services and uses image one SRC, which is on my CDN, and allows me to then actually send a push notification onwards. So this is where I can say I can send generic if I was to use, for example, here, my alternative is with notifications hub service dot send null, send all devices, message, this will be pushed irrespective of platform. So what will happen if we use this one and said was that if it was an iOS device, it would receive it. The one up here would not send to iOS because it would not support it. So you'd have to use notification service dot APNs dot send toast. And then you can actually send to the specific one and then you can actually put in the correct different attributes that you require for an iOS device. And it would say just broadcast to all connected iOS devices do the following. Notification also hubs also support tags whereby I want to sign up for a specific function or like, for example, news broadcasts. Send me like if we look at Twitter, I only want to send notifications of DMs and actual interactions. I don't want to be sending notifications up for every actual tweet. You can actually say, OK, subscribe to that. And then you can get your application to say, OK, you have this broadcast of this. If you have this broadcast of that, it will send to the person who has registered with that particular tag and broadcast to that particular device. You can then suggest that if I want to use APNs or Google Cloud Messaging, I can do that. Now that is push notifications. As you can see, it's written if you just use var azure is require Azure and then you will get the notification hub service up here. It'll work from that. Right. OK, so it's been recovered, recovered, recovered a bit more and we'll see what else we can do. This is where I was there. I hope to God this works because it fails so many times that it's just yeah. If you're going to scale your application, what happens when things go viral? How do you react? You have developed the new flappy bird, flappy bird, as we all know, the very addictive game. Your application has been picked up by 100 people on the first day. That's fine. My servers can handle it. It's now been picked up by a million people the next morning. It's now been picked up by 100 million the next afternoon. How do you scale from 100 people to 100 million people in 24 hours without using the likes of the power of the cloud? What the application, what mobile services does is it provides you with a back end that will actually expand if you need it. We are all hunting when we design applications for the application that will generate enough cash. But if we can't keep up with the demand of it, it will fail. If your users cannot connect to the device or cannot connect to the service and it keeps timing out, it will be people who are fickle, 15 minute attention span, it's gone. However, if your application is going superbly well and people can still access it, it generates viral word of mouth and continues on. The more you expand, the more the Azure application can expand with you. So if we were to look at how to scale, it's quite simple. It comes under the mobile services again and you just click scale. And you can expand out onto different, on the free tier, you get like 500,000 calls and up onto the standard tier, you get 15 million calls per device up to a certain amount of units. You can also say I want to move all these units and expand my application to react with it. As we know, cloud, one of the selling points of cloud is actually elasticity of the service. In other words, I will only, when I expand and I use all my current resources, I expand more. And if I don't need those resources, I just return them back. So the elastic version of this, it can be used. This is why I'm saying, if you have a back end that actually needs to scale very quickly, you can do this. Right now out of the box, you get 20 megs for free. But if you need more data, you've got to, of course, get into a different SQL server for that. Right. I'm going to talk a little bit about disaster recovery because I think that it's actually something we should talk about and custom API. The custom API allows you to see, and you see also mobile services. Right. First off, custom API here. Allows you to create endpoints that can be run over, get or post on rest. So in this case, where I've ascended SMS, I've send permissions to, I can say get permissions. Anyone with the actual can do a get request and it will send an SMS. Or I can say anyone with an application key, only authenticated users, for example, things like that. What I've done is I've set up an integration with Twilio. Has anyone know how to pronounce that? Twilio. Sorry, guys. And in Kudu, which is the back end for Azure Mobile Services and all the back end for websites, you can install Twilio support using MPM installed Twilio. And that will actually allow you then to generate against the Twilio service. Have you all seen Twilio? It allows you to generate SMS and call voice programmatically. So for example, you want to implement a service whereby I want to note, I know I'm going to send push notifications, but I want to send SMS, for example, I want to provide a service where I'm going to send SMS to my users as well. So I can say, okay, on this, do the following. But on Azure Mobile Services, what you do is you install Twilio, install against the API permissions, just give it whatever ones you want. And then your script here is I'm going to exports.get. So for the get protocol, I'm going to create a new Twilio REST client, and I'm going to send an SMS from this to myself. And that's it. So to do that, it's then ndcausler. For slash API. Send SMS. And yes, no. So this will just open and say it's null and it should. And it actually has sent me a text message quite happily. But it also explains how we're going to do logging. Because when we go back in here, it'll say console error success, success, the seed for this SMS is the following. So when I go back into my logs, I can actually see the information message was sent on this day and the six seed for this was, I can send notifications were successful. This is my logging function. We recommend that you only log errors, don't log warnings, don't log information because logs fill up very quickly and you have to truncate them every so often. Very simple, but the idea that you can export this log back out and read it using like, so, for OCO or new relic, or sorry, use it using new relic to keep an eye on your application means the integration goes much simpler. Back here with Kudu. Kudu is the back end. You can actually just see the what's actually running app settings, for example. It's much easier if I do it in Chrome because I got a JSON viewer there. Okay. Any questions while I'm waiting for this? Done so far? Yes, sir? Do notifications work with websites? Do notifications work with websites? Yes, I think you can actually send to, can you do push notifications? You can do push notifications. You can do push notifications to HTML5, I think, as far as I understand. If you have a website, can you make it to Azure website back? Can you show Azure authentication to all the pages? Oh, yes, yes, you can. Very good question. Can you use an application to do this? Yes, you can because, for example, if you use the custom API, for example, I can create an endpoint with like, say, post request. And I have a mobile services client with the authentication token. And what you do is you say post, do this and send this value in your application and we'll receive that data and then push all connected devices for you. So it's just running over rest. So it's quite simple that way. So if we look at the app settings here, we can actually see what is behind this with, like, it gives you of all the whole thing. So if it's available, like, this is a don't let this out in the world. Right. We're nearing the end of things. So showing the custom API. Yeah, this was where I was talking to one of the guys and he says like he did it with Twilo. Just be careful that it's again, not fully reliable delivery on the free account. So if you are using this type of thing, make sure you have a paid account to do it. Right. Whoops, wrong place. Close time. If you are continuing your Azure learning journey, please catch Nick Mollner's talk on Azure websites. It directly links into this a bit because it's running on the same kind of platform and you'll be able to integrate against mobile services for it. Also, try and get up and see Troy Hunt's talk. It's in Room 7 today. This is, you've learned how to do mobile services, learn how to secure your web applications while you're doing it. Because if you are integrating with anything like that, all this type of stuff needs to kind of, you have to think securely about it. Now, you should really go off and start creating applications because it's quite, as I've probably not quite effectively shown it's easy, but I'm sorry about that. It is actually kind of one of those things that as you get into it becomes much simpler and it takes away a lot of the pain points that we would have had as developers. For example, how to do notification services, how to integrate our databases into an application and share it across all devices. How to actually have a dynamic and build your front-end and just say, okay, get your database to just look the way it needs to do and in the back. Any more questions? Anything else? Going once, going twice, gone. Thank you very much. Thank you.
 All right, let's see if it's working. Woo, we have sound. Fantastic.  Right, there's a lot of people here. You actually found your way to Room 6.  It was kind of a little maze. It's like a whole way to work out.  If you're smart enough to get up here, you can be smart enough to leave if you want now.  It's okay. This is Windows Azure Mobile Services.  So if you're not ready for this talk or this is not what you're expecting, run.  I'm trying to get people out, I swear.  My name is Niall Merrigan and I work with Capgemini Norway.  And this is actually going to be Azure Mobile Services because Microsoft decided to drop Windows from their Azure branding  in a masterful move because everyone associates Windows with Microsoft and Microsoft with not running anything.  But Azure actually runs quite a lot of other stuff other than Windows, so they've decided to, that's why they dropped it.  It just means that all my slides are now a bit out of date.  But if you've got Twitter and the internet and stuff like that, you can tweet me at nmerrigan  and use the official NDC asl hashtag.  There is a rating system and feedback system for speakers.  As a speaker, I'm very narcissistic.  I do love when someone tells me I'm good.  I don't like when people tell me I'm bad.  But I do appreciate that I may not hit all your buttons on the one day.  So if there's something wrong, please tell us as speakers in general what is wrong.  Because if you don't, it's like sending in, there is a bug.  And I will reply back, there is a solution.  And you will go, for what?  And I'll say, for what you told me was wrong.  And they will go, okay.  So please, it's green fur, I like you yellow fur, I thought you were okay.  And red, I'm not what don't want to be your friend.  So it's very simple.  If you're colorblind, just pick something up and throw it in.  I'm Irish and I live in Ireland, or live in Norway actually.  But these are actual Irish road signs.  We advise you not to go with the speeding limit.  For our international audience, people running at home and stuff like that and whatever.  In Norway, the speed limit is about 80.  And this scares a lot of Norwegian drivers.  Because it's on the wrong side of the road and going up a cliff and you can fall off.  However, Norway does like you to enforce the speed limit.  So they just put tanks beside their photo boxes.  I'm sorry, sir, you're getting two points in your car.  Done.  I work with Capgemini Norway in Stavanger.  I am the head of custom software development there.  I am an ASP.Net MVP, ASP insider, member of many developer advisory councils, general, shouty person.  And today this is going to be about Azure Mobile Services.  Now, back in the old days, when most of us were small and didn't know what a computer was,  this was a database.  This was our computer.  And people generally, if they worked in one language, stayed in one language.  If they worked in one technology, they stayed in one technology.  Hi, I'm a VB developer.  I write forms and line of business applications.  Hi, I'm a Silverlight developer.  I'm extinct.  Hi, I'm a Cobalt developer.  Sorry.  I try to shove that in.  Hi, I'm a Cobalt developer. I'm old.  I don't do anything else.  That's all I did.  I very much focused on one technology, one language, nothing else.  Now, we are all multi-platform.  We're all about multiple different devices, multiple different technologies.  If I asked any developer here, most of you would say, I know one language.  I can probably do SQL.  I'm learning two others as I'm going along.  I'm working on.NET.  I'm working with Linux.  I'm working with Mac.  I work with many different application technologies and platforms.  But something that always remains in the background is the very humble database.  It is, for a lot of people, it's where they begin their development process.  It's a bad way to begin your development process if you begin with your database.  But if you want to now share your data across multiple applications,  which is a given in today's society,  the idea that I would actually have to pick up something off one computer,  and carry it to another device or something else,  and load it up there is like incomprehensible.  How many of you, if I said, sorry, do you want a copy of that code?  Okay, will you come over to my computer, put in your USB stick, take it off,  copy it over to your other device, and you're like,  but why can't you just share it online, or why can't you just share it somewhere else?  This idea of me having to physically move from a device to get the data is gone.  The problem is, if you have to share all this data, how do you scale up?  And how do you share all this data? Do you build your own data center?  Do you make your database accessible to all the world?  Or do you say, well, you know what, I can deploy a back end in the cloud,  or I can just make a back end available?  And this is what Azure Mobile Services is.  It's your back end in the cloud.  This is the product slide for this, and it says, you know, it hasn't been updated yet,  but it's all about the data.  You can store data in the cloud that can be shared across multiple devices.  It also gives you push notifications.  Now, notifications have become the de facto way of telling people  or something you have to do with your application.  We don't expect customers to actually open up our app,  refresh to see if something happened, and then close the app.  Customers like to be notified.  Hi, you've got something you need to look at.  Please look at it.  Okay, we're gone beyond the idea of, I'll just go check my mail to see if I have mail.  It's like, I expect a notification, I expect a buzz, I expect something to tell me  that there's something for me to look at.  Notifications are a standard now that you have to use in any mobile device.  And now, for example, in other applications such as Windows 8,  you have push notifications based on the desktop.  We've seen it in browser for a long time,  but now it's becoming in the application on the desktop as well.  We now also think of authorization and authentication.  Do you like remembering passwords and usernames?  How many of you do?  Anyone's? No?  No one likes to remember using it.  How many of you say, okay, sign up with Facebook or Google or Hotmail or whatever,  and go, okay, great, click the button, done.  One less thing I have to remember.  Sorry, is that something I like doing?  I do, sorry.  Troy Hunt is here.  He's a security guy, so if you're going to see his talk,  he'll have a lot more of these fun questions.  You've got server logic.  We've gone beyond the idea of putting code on the front end that cannot be shared,  and any time I have to do an update, I have to put an update to my application.  We had for a long time, end tier applications where business logic stayed in the middle tier  and data logic stayed in the bottom tier, and then you had front end just visualization.  The exact same thing happens here.  I want to store stuff that is common to all my devices and all my platforms in the one place.  If I need to change it, I update it once.  I don't need to update my application.  Why do I want to do that?  You've diagnostics, you've logging and scale.  Right.  I think we should start and show you how it works.  We'll just start with a little demo.  This is how I think these demos work.  Let's do it.  Welcome to the Azure portal.  How many of you have seen the Azure portal?  Everyone?  Actually, first off, question. How many of you know what the cloud is?  How many of you don't know what the cloud is?  Good.  Because I would say if you want to see the cloud, just look outside.  It's wet.  If you want to create, it's very simple, login with your LiveID, create a new, very simple mobile service, click create.  We are going to create a URL which I'm going to call ndcauslowv2.  I have a v1 just in case everything goes tits up on this because it did before.  Use a new database.  You get 20 megs free.  Database all exists for Azure.  Okay, using existing database.  West US, I think I'll go for North Europe.  You can actually use either JavaScript or.NET preview.  Personally, I prefer the JavaScript version.  The.NET is kind of web API stuff I'm built in.  I don't know.  I think when I'm doing mobile services, because it started off in JavaScript, it's just a bit more easy and it kind of sits that fluid way of working.  I'm thinking that's what we should be using.  I'm just going to just do...  You must follow by a SQL password.  Okay.  We might just use any creating a SQL instance just in place.  It might be just easier.  ndb, configure server, North Europe.  Now...  And we click OK and we provision.  So we wait a little bit longer.  Following mobile services is not created.  Database percentages are incorrect because firewalls are...  Fantastic.  Right, we're going with the one that I've created before, just in case.  I honestly think that this has the demo gods of going, we will smite you.  Smite you hard.  I didn't say everyone starts with a hello world.  I know I'm sorry. I didn't start with a hello world.  All right, let's do this.  And we'll bring up Visual Studio and I'll have my ndc-osl app.  Okay.  You can actually download an existing create new store app and just create...  And just download this.  And it will download a very sample app which we're going to use because it's nice and simple, open folder.  One thing is if you download it, remember to unblock it because otherwise it will tell you you have to do that for everything.  And it becomes quite annoying.  Now we wait 15 hours for Visual Studio to load.  Woohoo!  It decided it would wake up today.  I spoke too soon.  I spoke too soon.  Oh, God, come on.  Hello?  There we go.  ndc-osl unavailable.  Why could you not...  That's probably because I'm reading this.  We'll go into Server Explorer and inside here we can see in the tooling,  I can see the mobile services that I have existing already.  Now it's going to tell me I need to put in my password.  Or I hope not, maybe not.  I can see that I have an ndc-osl application written here.  If I go back to my mobile services,  as you can see it maps up to the two ones I have here.  It's very simple to see all this.  In ndc-osl, this is my dashboard.  And it shows me as my mobile service what's actually happening.  I've got a mobile service URL.  It's running on HTTPS ndc-osl azuremobile.net.  And I've got a database against ndc-osl db.  I can see my data.  I've got an API, custom API.  I've got a scheduler, push, identity, logs, etc.  What I'm going to do here,  if I can see if this will work for me,  we are just going to,  I just have to rebuild this quickly.  Actually we'll just press F5, it will be fine.  If we press F5,  and we wait, wait some more.  Activation requests this error because the screen resolution is before.  This is just fun.  Screen resolution.  It's 1280 by 720.  Alright.  Turn it to 11.  Okay.  Can everyone still see the screen?  We're all good. Excellent.  I bet you it's, no, we're okay.  Registration successful.  This is for push notifications.  So when I insert it to do item,  I click save.  It should save this out.  Okay. No reference exception.  I'm sorry.  I know it's like, sorry.  I'm not having a good day today, am I?  Alright, one second.  Yes.  The problem with the screens as well.  It's like an etch-a-sketch.  The problem with screens, let me just...  Sorry, the joke was it's like an etch-a-sketch up here,  so they're just going to flash the screens.  Are we still good? No?  We're not good? Alright, let's do a screen resolution down again.  1336 by 768.  Apply changes.  Is that all there?  Alright.  Let's see what's going on.  Okay, we'd have to go back and see what actually  the mobile service is doing when we look at our database  in order to do item in our script.  So we have an sent to script, and we'll do that.  Okay. Refresh to do items.  Let's just see what's going on.  Refresh to do items.  So if we go at five, it says invalid in there, so that'll be fine.  But I'm going to open up the... Close this.  Close that.  We'll bring up the other one.  And see if that'll work for me.  Oh, the demo gods, they are fun.  So while I'm burning here on stage...  Yeah.  Ha ha ha.  Oh, there's always one funny Englishman in the back, isn't there?  So if we go back to...  Where's my v2 vision of that?  Alright.  At least my son is still smiling.  At least my son is still smiling. That's right.  That's...  Distract all.  Okay.  Let's see if this will work.  Close that.  I'm sorry about this.  This is always the mobile services talk.  It works fine. It works on my machine, TM.  I should actually just record this the whole thing and just say it actually does work.  Well, while I'm here, we'll talk about it a bit more.  In our side art to do item here on our table,  we have a database that actually supports dynamic data.  So what you can do is it has a dynamic schema enabled.  This here means that as I build my application,  you don't actually have to define what the table contains.  I can actually say, please just use whatever object I'm sending in  and build the schema accordingly on the database.  So for example, say I have my to-do item here.  If it will show me, let's see. Excellent.  If we go back to main page, yes.  We have a to-do item here, which has got ID, text, and complete.  It's got JSON property. Should pick it up. Come on.  And as we use this, and I'd say actually what's happening here  is it just needs to get the package manager, tools.  You get package manager and restore.  Oops, sorry. Tools.  You get package manager, restore these.  So what will happen is that it will build.  We should be just closing this.  I'm finished. Great. Done.  Now, have we got this? Can it resolve symbol?  Oh, fantastic.  So what it will do is it will put in the ID, text, and complete.  If we go back to our mobile services here in...  Did it bring up V2? Mobile services?  Oh, yeah, because it didn't create the NDC also.  So there we go.  In our data, when I create a to-do item,  it actually generates in the columns.  It'll show me that it will generate the text,  and complete an ID parts by actually adding those in.  So...  Why is this not picking up?  Yeah, I'll try to build. Just to make sure for build.  It's all started. Should pick it up fairly quickly.  Build succeeded. Lovely.  We're still giving... There we go. Thank God.  Something actually works today.  So if we look here, as it creates...  When it creates the sample item,  you actually create a new mobile services collection.  It creates against the to-do item table,  which just gets a get table to-do item.  So it maps up against the get table.  It will then says, I want to wait, insert async to-do item,  and then just click add.  It sends that up to the browser, and what are up to the mobile service?  The mobile service will receive that for the insert command,  and say, okay, what do I want to do with this request?  I want to do a database.  Right. I've got a number of different properties I don't recognize,  but they're JSON serialized, and so I can...  Because I've got dynamic schema enabled,  I will just expand my schemas to actually match those object types.  And that's all it has to do.  So if I press F5, this should actually connect up to the other one.  If we're working. See, there we go.  We've got to refresh our data so far, so good.  Sample item, insert.  If we click save.  Okay, so it just sends me back a push notification,  because I've enabled it for push,  and down here, sample item is inserted.  Now, if we were to change that actual command  to insert a new item into-do, it would actually expand the table,  and we'll do that in a minute  when we're going to do enable authentication.  This is a very simple to-do item,  but it shows you that I can save data up to the cloud and send it back.  If I then put it into, for example, a mobile device,  and I connect up to the exact same table,  that device will have the same data,  because it'll have the application key.  If I go over to the server explorer here, and back in,  I can... If I go into mobile services...  A bit more, and I go to ANDC Oslo.  We have our to-do item, which I can expand here,  and I can actually see that on the insert,  I can see the actual code that I'm writing against it.  Now, this particular piece of code, it says,  I want... When you insert, I want to send a response that I've inserted,  but I also then want to send a notification,  which uses notification hubs to push a notification  back to all connected clients,  and I'll explain that in a second.  Now, if I want to add authentication,  to do this, I would actually have to go into Facebook...  Like, for example, if I want to add Facebook authentication,  if we go back and explain a little bit about this.  On Facebook authentication,  you need to set up a developer account on Facebook.  So that goes to developers.facebook.com,  register yourself as a developer,  and then you will be given this effectable dashboard for here.  Very simple. I've created a demo account here.  I create apps, create a new app,  and this will come up with a display name,  and you have to use a unique identifier here.  Just note, it has to be lowercase for this,  and then just choose a category and create the application.  Once the application has been created like here,  you then add a new platform for it.  So that goes into settings, click Add a Platform,  put in your site URL to your mobile device,  or your mobile services, go back...  Once you have that, into dashboard again,  you go back and forth a little bit,  I'd love this to be a bit simpler,  copy out the app ID and the app secrets,  go into mobile services...  Hello, mobile services, yes, thank you.  And we go into identity.  And here, I can put in my different authentication schemes.  So I have my app ID and my app secret.  You can add Twitter.  The thing with Twitter is that if you're doing this  against local hosted, it will fail.  So it's a valid, actual account that will do it.  What I recommend if you're trying to test locally against  with Twitter authentication against mobile services  is instead of using local host,  use a domain name that is just you have in your host file.  So it will just map like example.com,  and you say example.com.  Yes, you can copy the key and I will look at it in a minute.  It's fine.  Sorry, the security guy here is just making jokes.  It's not funny.  It's bad enough up here as it is.  So with Google and also with the Windows Azure Active Directory,  and you have the Microsoft Live ID if you wish to use that.  So once that's done, to enable security on your application,  you click on permissions.  And right now, it says the insert permission is anyone with the application key.  So if I've got the application key to this application, you can use it.  A word of note, the application key here is kind of sounds like it's a security token.  If you're using authenticated login,  if you just want to use login, use your mobile services to do your login,  or OAuth login, the application key is actually not required.  So because the actual JavaScript involved in this  doesn't actually respect the authentication key.  So any application can use your mobile service to OAuth.  Now, it's, well, it's just, it's no big deal,  but it means that you'll end up with a whole lot of service calls,  and it could, you end up with possibly an idle service attack, whatever.  Yeah, it's one of those things that I kind of found a bit weird that it didn't allow you to do that.  So with the read permission, I'm just going to change it to only authenticated users,  so it'll actually force the application to be authenticated at the start.  Now for the application, it will be, to do the insert,  you will need to have an authenticated token.  We click wait for permissions.  Good chance to get a glass of water.  Have there been any questions so far?  Anything at all?  This is kind of weird. It's a real long, yes, sir?  If you're more than one developer working on mobile services, how can you connect?  If you're more than one developer working on mobile application services,  how can you connect as in?  So to this interface, I want to share with somebody else.  So more than one developer or a team?  Yes, and you want to use the actual, not this interface,  like for example, you can use Visual Studio if you wish,  but the thing is if it's a shared account, it'll have to be like a company account,  which would mean that when you connect up here and use server explorer,  and you say connect to Azure, you connect to Windows Azure,  you actually, I'm currently selling this as my actual live account,  but if I had an actual corporate account or something that was shared,  you could actually use that in that case.  Yeah, it's a cost issue, of course, but the thing is if you have a corporate account,  in other words, this can all be server free, but say for example,  you have a shared email address, mycompanyatlive.com or outlook.com,  and say 20 developers have the password for it, they can all connect.  It's not going to say that it has to be just one developer.  In other words, I can have this running on four machines side by side,  and it's not going to worry that, but you'll have concurrency problems  if for example, someone changes something and it's code.  It does support Git on this,  so if you want to do actual changes and push back and forth,  you can actually do that instead, and actually develop locally,  push up to Azure and it'll work.  So good question to answer is you have to have a shared email address  that people will use.  So to go back to our authentication, we should have now been authenticated.  We've done, all right, excellent.  So if I go into NDC also again, and I go back to my solution and main page.  To actually authenticate, I need to insert my snippet,  which is add a mobile service user to tell it that I want to have something  that I can store the user credentials against and authenticate async.  So I added a new function called authenticate async.  And what this does is you see here, it says,  await app.mobileservice.loginasync, mobile service authentication provider.facebook.  So it will use.facebook.  And if you, sorry,.facebook, it will use Facebook.  So you have the option here of.facebook, Twitter, Microsoft account,  and Windows Azure Active Directory.  So we'll go back to Facebook.  Excellent.  And then to do that, we will have to tell it that on the,  when the, where is it going down here?  Back down here, refresh to do items on navigator two.  It will be await authenticate async.  And that will give an error because I need to put override async void.  Now, press F5.  We pray to the demo gods a little bit.  Again.  We hey.  So it will come up with my connecting to service.  Come on.  There it is.  As you notice, I'm using a very nice effective hidden domain thing called opaque.  I actually really love this domain name opaque for those who actually speak English.  It's quite funny, but those who don't, it's going to, huh?  And I'll keep me logged in.  I'll log in.  Now you're logged in as Facebook user X.  So it will now authenticate, it's now I've actually authenticated against my mobile service  in what can be considered a couple of different clicks and running around.  But that's it done.  There are the easy bits.  What we're going to talk a little bit more about now, if we go to Homer,  we have our hammer time, active directory.  We're going to talk a bit more about push notifications.  Push notifications have come a hell of a long way.  Right now you have Windows notification services,  Windows phone notification services,  Google Cloud messaging, Apple push notification services.  And if you want to push to all different devices,  you kind of have to kind of know how to send different posts and tiles to those particular devices.  It seems like a lot of work.  As a developer, I like stuff being easy.  I like stuff being wrapped up a little bit that I can just say,  make it work. I'm happy.  That is where notification hubs come in.  They are now in preview right now, but what they allow you to do is,  hi, I want to send a message to everybody.  Great.  Who do you want to send it to?  Well, all connected devices.  You fix?  It goes, I fix and just sends it out.  It'll do a simple push notification to all devices that,  regardless of device type or push notification service you need,  it will just send.  However, you can actually override it and say,  okay, I want you to, for Windows notification services,  I want you to send this type of posts and tile to it.  No problem. I can do that.  So we want to show you how that actually works.  When you, to enable push notifications,  normally what you will do is you'll right click on your application up here  and just go to, where's it at?  And you have a push notification and it will enable push notifications on your application.  It takes a couple of minutes, but what will happen?  It will ask you to register a namespace and an actual application name.  So when you go into Twitter, go away, maybe go away,  sorry, we'll bring this back up,  you have a dev center for Windows.  And when you log into this, keep me signed in,  this will register your application against the dev center  and it'll give you an application name.  So for example, here, I have NDC Oslo.  When I go to click on edit this,  this will show me the different, this does it automatically for you.  As enabling push notifications gives you, as far as number five, this piece done,  it gives you your app name, reserves it,  and then says it enables push notification services on your application.  So it sends this client application secret back to you.  When you go into your live services site here,  again, this is the thing, it kind of wraps,  enabling push notifications on mobile services wraps this up a little bit easier for you  so you don't have to worry as much about doing all this stuff.  Before, it was a manual process of sign up to the dev center,  sign up to live services, this just enables it.  But it gives you your application identity, your client ID, and your client secret.  And these are all built back into the push notification service here.  I'm going to show this.  It automatically pre-populates those back into your application.  But this is a subset of the Azure service bus.  So when we go into the NDC Oslo hub,  I can see my notification hub here, which is directly linked back to my mobile service.  So that's what it provisions.  It provisions an Azure service bus, which provisions internally in that,  an actual notification hub.  This allows you to send your push notifications to any connected device.  What happens, how does your device actually receive notifications?  It simply says, when I connect to your service, I'm going to register a channel URI.  Great.  And then our application holds that, and we'll use that for sending information back.  You do this every time you actually register your device against your mobile service.  So in our application, I'm going to take out my await here,  because I really don't want to have to log in every five seconds.  And I'm going to go into app.sammal.  And I'm going to enable push notifications.  I'll just add it here.  So if I add push notifications, it does this, sign up windows,  sign into windows store.  And we have to go here.  Yes, I don't know my own passwords for stuff anymore.  Text it, okay.  What could possibly go wrong with two-factor authentication?  I feel like it's like the guy who has to open all the locks and you hear,  ch-ch-ch-ch.  Submit.  Yay!  So I've got NDC Oslo here, and it'll do that and click next.  It'll look it up to a different subscription, which I already have.  And I'll say NDC Oslo, next.  Finish.  Temptons to all windows Azure and mobile services.  This takes a little bit of time.  Okay, any of the push notifications services.  Done.  And done.  So that's it done.  We have our function set up that will notify all users and send an SMS.  Excellent.  Fantastic.  Okay, so that's enabling push notifications on the server.  Now we have to enable it in our application.  So that's quite simple.  Go in here.  And we set up a new function.  Thanks.  And do micro snippets and initialize async down here.  Yes, there we go.  I forgot how to do this before, so love mom, thank you mom.  Package manager is off.  Yeah, there we go.  It should have just done it already.  And just paste.  And then you can't solve.  Paste.  Hello.  Install package. Come on.  There we go.  Remember when I said this thing is reliable.  For all definitions.  Messaging.  Dodd managed.  Oh, great.  Fine, fine, fine, fine.  It's just not funny.  Oh, no, it is.  Trust me, it's hilarious.  It's hilarious, isn't it?  All right, fine, fine, fine, fine.  Why are we not doing this?  Now you do that.  And so in the application app, okay, yes.  Create a new class notification app.  No, I want to install the package.  Install package.  Microsoft.  Azure. Windows Azure.  No, not activities.  Azure.Messaging.Managed.  Why is it not giving me this?  Yeah, I thought so.  But that's why it just says install.  It should install the package for me.  So install this.  Oh, I love you.  What the hell?  Yeah, I'm going to just search for it and we'll find out.  And then we get a package manager.  Don't need messaging.  Messaging.Managed.Installed.  There we go.  Yes, I accept.  Was that so hard?  Oh, thank God.  I love it.  So we need to init then in, and I just removed this.  I'm going to say init notifications async.  Okay, f5 that.  Messaging was not handled in user code.  What the hell?  Oh, yeah, that's because I forgot to end up with the endpoints.  I know that would help.  Well done, now.  Okay, so that explains my next point, what you actually should do when you want to set this up.  You manage the connection information.  So the hub is called entity Oslo hub, and we want to use that here.  And then we want to listen endpoint, which is just going to be here.  And do that and put that in over here.  I think it'll just, I think it's, yeah, I probably just, oh yeah, I've got extra codes there.  Thank you.  I'll go back here to this.  All right, f5 this now.  This is actually a great way to show you how not to develop.  Don't ever come up and try and do live coding.  Error loading items.  Access is denied.  Of course access denied because I forgot to take off the identity.  So this is the really how you do the development environments kind of thing.  It's like it actually shows you how to debug.  So, yeah, that's how most of us do it as well.  Yeah, that worked.  Did any of you see Anthony's talk on solid for CSS?  He was talking about spaghetti code in JavaScript.  And I was thinking of saying, well, mostly spaghetti code in JavaScript happens because it works.  Don't touch it.  We're not going to, I don't know what actually why it works now, but it does work.  And I don't want to stop permissions.  So we'll just take that from any of the application key and any of the application key and click save.  All right, so 20 minutes.  We're fine.  I'm going to go on and talk about disaster recovery, but it'll be kind of interesting because it's.  Yes, go on, recover.  Yes, registration successful.  So when I send this information here, come on.  Save.  It should send me a notification.  So there it goes.  Now, that is a very simple notification.  What I've done here is when it inserts, I have changed the code on the insert script to say the following, send notifications.  It uses Azure require.  So this is no JS and just as require Azure.  You say, not create notification hub service.  I've put in my endpoints that I've required the exact same thing.  The hub and the endpoint and then said, just send WNS, send toast text to do this.  Yeah, that's okay.  We can, but we can actually use the custom API to test this as well in we have logs or is it no, it's in configure, I think.  I'll show you in a sec.  The where's it API.  I've got a notify all users here, which will allow me to do a test notification if I want and then pushes and that'll allow you to if you run it, you'll actually send a notification to it.  But to test it, what you actually can do is go into your hub and you're going to notification hubs.  And you can click debug and you can do a random broadcast and you can send it to, for example, windows.  And I can select notification type, just a tile and it'll give me some test message here.  Or I can say I just do that and it'll just click send.  Do you want to, yes.  So it should actually broadcast to this device here.  I hope all random devices may not.  Yes.  So let's try and do a send and send test message.  Send.  Send to us notification.  And probably now what will happen is I'll get about four notifications in one go because notifications are best effort.  They're not actually fully reliable, which is a bit of annoying thing.  But if I want to do random broadcast, send a tag, it'll just send it down.  What push notifications you can do further on is if we go to our back to our mobile service again.  And go into our API.  We can, for example, send a notification hubs here to this.  Now if I bring up my notification hubs here.  See if I've got this.  Hello from mobile services.  Scheduled up.  Yes, I have a sample notification.  If I go into my scheduler, I've got a sample push set up here in the script.  And what this uses is a more advanced version of the hub.  It's still the same hub, but it allows me to send, for example, here, send toast image in tech 01.  So it'll actually allow me to send a run once.  And I get a hello for NDC also, complete with badge, et cetera, and the whole lot.  So I can actually send to specific.  This will use the Microsoft or Windows notification services and uses image one SRC, which is on my CDN,  and allows me to then actually send a push notification onwards.  So this is where I can say I can send generic if I was to use, for example, here, my alternative is with notifications hub service dot send null,  send all devices, message, this will be pushed irrespective of platform.  So what will happen if we use this one and said was that if it was an iOS device, it would receive it.  The one up here would not send to iOS because it would not support it.  So you'd have to use notification service dot APNs dot send toast.  And then you can actually send to the specific one and then you can actually put in the correct different attributes that you require for an iOS device.  And it would say just broadcast to all connected iOS devices do the following.  Notification also hubs also support tags whereby I want to sign up for a specific function or like, for example, news broadcasts.  Send me like if we look at Twitter, I only want to send notifications of DMs and actual interactions.  I don't want to be sending notifications up for every actual tweet.  You can actually say, OK, subscribe to that.  And then you can get your application to say, OK, you have this broadcast of this.  If you have this broadcast of that, it will send to the person who has registered with that particular tag and broadcast to that particular device.  You can then suggest that if I want to use APNs or Google Cloud Messaging, I can do that.  Now that is push notifications.  As you can see, it's written if you just use var azure is require Azure and then you will get the notification hub service up here.  It'll work from that.  Right.  OK, so it's been recovered, recovered, recovered a bit more and we'll see what else we can do.  This is where I was there.  I hope to God this works because it fails so many times that it's just yeah.  If you're going to scale your application, what happens when things go viral?  How do you react?  You have developed the new flappy bird, flappy bird, as we all know, the very addictive game.  Your application has been picked up by 100 people on the first day.  That's fine.  My servers can handle it.  It's now been picked up by a million people the next morning.  It's now been picked up by 100 million the next afternoon.  How do you scale from 100 people to 100 million people in 24 hours without using the likes of the power of the cloud?  What the application, what mobile services does is it provides you with a back end that will actually expand if you need it.  We are all hunting when we design applications for the application that will generate enough cash.  But if we can't keep up with the demand of it, it will fail.  If your users cannot connect to the device or cannot connect to the service and it keeps timing out, it will be people who are fickle, 15 minute attention span, it's gone.  However, if your application is going superbly well and people can still access it, it generates viral word of mouth and continues on.  The more you expand, the more the Azure application can expand with you.  So if we were to look at how to scale, it's quite simple.  It comes under the mobile services again and you just click scale.  And you can expand out onto different, on the free tier, you get like 500,000 calls and up onto the standard tier, you get 15 million calls per device up to a certain amount of units.  You can also say I want to move all these units and expand my application to react with it.  As we know, cloud, one of the selling points of cloud is actually elasticity of the service.  In other words, I will only, when I expand and I use all my current resources, I expand more. And if I don't need those resources, I just return them back.  So the elastic version of this, it can be used.  This is why I'm saying, if you have a back end that actually needs to scale very quickly, you can do this.  Right now out of the box, you get 20 megs for free.  But if you need more data, you've got to, of course, get into a different SQL server for that.  Right.  I'm going to talk a little bit about disaster recovery because I think that it's actually something we should talk about and custom API.  The custom API allows you to see, and you see also mobile services.  Right. First off, custom API here.  Allows you to create endpoints that can be run over, get or post on rest.  So in this case, where I've ascended SMS, I've send permissions to, I can say get permissions.  Anyone with the actual can do a get request and it will send an SMS.  Or I can say anyone with an application key, only authenticated users, for example, things like that.  What I've done is I've set up an integration with Twilio.  Has anyone know how to pronounce that?  Twilio.  Sorry, guys. And in Kudu, which is the back end for Azure Mobile Services and all the back end for websites,  you can install Twilio support using MPM installed Twilio.  And that will actually allow you then to generate against the Twilio service.  Have you all seen Twilio?  It allows you to generate SMS and call voice programmatically.  So for example, you want to implement a service whereby I want to note, I know I'm going to send push notifications,  but I want to send SMS, for example, I want to provide a service where I'm going to send SMS to my users as well.  So I can say, okay, on this, do the following.  But on Azure Mobile Services, what you do is you install Twilio, install against the API permissions,  just give it whatever ones you want.  And then your script here is I'm going to exports.get.  So for the get protocol, I'm going to create a new Twilio REST client,  and I'm going to send an SMS from this to myself.  And that's it.  So to do that, it's then ndcausler.  For slash API.  Send SMS.  And yes, no.  So this will just open and say it's null and it should.  And it actually has sent me a text message quite happily.  But it also explains how we're going to do logging.  Because when we go back in here, it'll say console error success, success, the seed for this SMS is the following.  So when I go back into my logs, I can actually see the information message was sent on this day and the six seed for this was,  I can send notifications were successful.  This is my logging function.  We recommend that you only log errors, don't log warnings, don't log information because logs fill up very quickly and you have to truncate them every so often.  Very simple, but the idea that you can export this log back out and read it using like,  so, for OCO or new relic, or sorry, use it using new relic to keep an eye on your application means the integration goes much simpler.  Back here with Kudu.  Kudu is the back end.  You can actually just see the what's actually running app settings, for example.  It's much easier if I do it in Chrome because I got a JSON viewer there.  Okay.  Any questions while I'm waiting for this?  Done so far?  Yes, sir?  Do notifications work with websites?  Do notifications work with websites?  Yes, I think you can actually send to, can you do push notifications?  You can do push notifications.  You can do push notifications to HTML5, I think, as far as I understand.  If you have a website, can you make it to Azure website back?  Can you show Azure authentication to all the pages?  Oh, yes, yes, you can.  Very good question.  Can you use an application to do this?  Yes, you can because, for example, if you use the custom API, for example, I can create an endpoint with like, say, post request.  And I have a mobile services client with the authentication token.  And what you do is you say post, do this and send this value in your application and we'll receive that data and then push all connected devices for you.  So it's just running over rest.  So it's quite simple that way.  So if we look at the app settings here, we can actually see what is behind this with, like, it gives you of all the whole thing.  So if it's available, like, this is a don't let this out in the world.  Right.  We're nearing the end of things.  So showing the custom API.  Yeah, this was where I was talking to one of the guys and he says like he did it with Twilo.  Just be careful that it's again, not fully reliable delivery on the free account.  So if you are using this type of thing, make sure you have a paid account to do it.  Right.  Whoops, wrong place.  Close time.  If you are continuing your Azure learning journey, please catch Nick Mollner's talk on Azure websites.  It directly links into this a bit because it's running on the same kind of platform and you'll be able to integrate against mobile services for it.  Also, try and get up and see Troy Hunt's talk.  It's in Room 7 today.  This is, you've learned how to do mobile services, learn how to secure your web applications while you're doing it.  Because if you are integrating with anything like that, all this type of stuff needs to kind of, you have to think securely about it.  Now, you should really go off and start creating applications because it's quite, as I've probably not quite effectively shown it's easy, but I'm sorry about that.  It is actually kind of one of those things that as you get into it becomes much simpler and it takes away a lot of the pain points that we would have had as developers.  For example, how to do notification services, how to integrate our databases into an application and share it across all devices.  How to actually have a dynamic and build your front-end and just say, okay, get your database to just look the way it needs to do and in the back.  Any more questions?  Anything else?  Going once, going twice, gone.  Thank you very much.  Thank you.
Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_0_7511.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_7512_11159.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_11160_11303.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_11304_11867.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_11868_14891.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_14892_15227.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_15228_15707.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_15708_17171.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_17172_17291.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_17292_17459.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_17460_17699.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_17700_17903.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_17904_18755.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_18756_19019.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_19020_19187.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_19188_21251.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_21252_21503.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_21504_21983.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_21984_23603.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_23604_30131.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_30132_31055.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_31056_31307.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_31308_35639.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_35640_37559.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_37560_37691.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_37692_38831.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_38832_38951.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_38952_40763.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_40764_42587.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_42588_43739.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_43740_46031.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_46032_47987.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_47988_48935.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_48936_54647.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_54648_58523.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_58524_59867.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_59868_59939.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_59940_60131.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_60132_63455.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_63456_65507.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_65508_66935.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_66936_67247.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_67248_70055.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_70056_70271.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_70272_71207.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_71208_71495.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_71496_71567.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_71568_72167.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_72168_73355.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_73356_73715.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_73716_74003.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_74004_75875.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_75876_76115.png Niall_Merrigan_-_Windows_Azure_Mobile_Services_from_the_ground_up_76116_76883.png