Download presentation
Presentation is loading. Please wait.
Published byColeen Sullivan Modified over 9 years ago
1
Azure 236504 – winter 2015/16
2
What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be a pain. Wells are expensive to build, and expensive to maintain. You wouldn’t be able get a large quantity of water quickly if you needed it—at least not without upgrading your pump. Source: Programming Windows Azure (Sriram Krisbnan)
3
What Is Cloud Computing? And if you no longer needed the well, there would be no store to return it to, and no way to recoup your capital investment. If you vacated the house, or the proper plumbing were installed in your house, you would have invested in a well you don’t need. Source: Programming Windows Azure (Sriram Krisbnan)
4
Some History At the beginning, programmers typed in code using punch cards or tape, and submitted the cards or tape to a machine that executed jobs synchronously, one after another. This was massively inefficient, since the computer was subjected to a lot of idle time. Source: Programming Windows Azure (Sriram Krisbnan)
5
Time-Sharing Systems Cloud computing has its origins in the 1960s, as the time-sharing systems appeared. Time sharing took advantage of the time the processor spent waiting for I/O, and allocated these slices of time to other users. Source: Programming Windows Azure (Sriram Krisbnan)
6
Mainframe Computing These are computers used primarily by corporate and governmental organizations for critical applications, bulk data processing such as census, industry and consumer statistics, enterprise resource planning and transaction processing. Source: Programming Windows Azure (Sriram Krisbnan)
7
Grid Computing VS Cloud Computing The term grid computing originated in the 1990s, and referred to making computers accessible in a manner similar to a power grid. Grid computing is about users making few, but very large, requests Only a few of these allocations can be serviced at any given time, and others must be queued Cloud computing, on the other hand, is about lots of small allocation requests, with allocations happening in real time. Source: Programming Windows Azure (Sriram Krisbnan)
8
Why Cloud? “Unlimited resources” Scale on demand #clients #services Out of the box infrastructure Redundant (geographical) Compatibility with different clients Less deployment management
9
History of Azure The idea: A new kind of software, that you don’t install from CD (2005) A trip to Hotmail led to the name idea “Pink Poodle” (2006) The chosen name was “Red Dog” Source: Programming Windows Azure (Sriram Krisbnan)
10
History of Azure The funding team worked in a startup-like fashion, they did things that weren’t normally done at Microsoft. Such as turning a nearby building into a small data center, and stealing power from the buildings around it Red Dog, now renamed Windows Azure, was officially unveiled on October 27, 2008. Source: Programming Windows Azure (Sriram Krisbnan)
11
Why Azure? Integrated into Visual Studio Many services in one place Mobile service Has API for both tables and custom APIs General computing- because Arduino computational resources are limited Connects to both Windows Phone and Arduino Course requirement
12
The Azure portal Azure control panel: https://manage.windowsazure.comhttps://manage.windowsazure.com Each of you will connect his Microsoft account to his Azure pass. Only one pass per account allowed! You need Visual Studio 2013 or newer. You can get it from MSDNAA: https://csms.cs.technion.ac.il:4423/ https://csms.cs.technion.ac.il:4423/
14
Mobile Service Software Stack AppService Controller Proxy JSON / XML HTTP ClientCloud
15
To Visual Studio! Preparing the solution You will need: Azure Mobile Service
16
To Visual Studio! Preparing the solution You will need: A Client Project We will use WPF In order to support Windows Phone you will need Universal App
17
Adding the Azure Libraries Managed by NuGet
18
Adding the Azure Libraries Search for “Azure” Add: “Windows Azure Mobile Services” and: “Windows Azure Storage”
19
Visual Studio Project Structure Solution (*.sln) Project – Client AppProject – Cloud Service class MyController : ApiController {... } class TodoItemController : TableController {... } AppService Ctrlr Proxy JSON / XML JSO / XML HTTP
20
Visual Studio Project Structure Solution (*.sln) Project – Client AppProject – Cloud Service public static MoblieServiceClient MobileService Defined in framework class MyProxy { public static async Task DoWork(Request r) { return await App.MobileService.InvokeApiAsync (... r...); } AppService Ctrlr Proxy JSON / XML HTTP
21
Async The Async keyword makes it easy to write multi-threaded non-blocking calls public async Task ExampleMethodAsync() { //.... } string contents = await contentsTask; task result = f(42); int x = await result;
22
JSON JavaScript Object Notation A lightweight data-interchange format “Self-describing“, easy to parse in code, human-readable {"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]} AppService Ctrlr Proxy JSON / XML HTTP
23
Naming Requirements In service project: class MyController : ApiController // must end with “Controller” public MyReturnType GetMyMethod(MyParamType p) // must start with Get/Post for HTTP Get/Post methods
24
Naming Requirements In client project: return await App.MobileService.InvokeApiAsync (“mycontroller/mymethod", MyParamType p HttpMethod.Get, new Dictionary ()...); // mycontroller – name of controller in lowercase without // “controller” // mymethod – name of method in lowercase without “Get/Post” // MyParamType, MyReturnType - parameter & return types // HttpMethod.Get must match method in controller // new Dictionary ()... – additional url // parameters
25
Other Constants In client project: In class App: public static MobileServiceClient MobileService = new MobileServiceClient("http://myService.azure-mobile.net/", “ApplicationKey");
26
Other Constants Find application key here:
27
Blob Storage
28
private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Get storage account object from connection string
29
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Get the blob storage client for the current storage account
30
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Get the container reference. This is the handle for the container.
31
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } This one is self-explanatory :)
32
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Get the blob reference. This is handle for the blob.
33
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Upload the byte array!
34
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Upload the byte array!
35
Blob Storage private static readonly string blobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=basastorage;AccountKey=" + "MyKey"; private async void StoreBlob(byte[] blobData) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(blobStoreConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); container.CreateIfNotExists(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("myBlob"); await blockBlob.UploadFromByteArrayAsync(blobData, 0, blobData.Count()); } Also has methods for string, stream and file
36
Publishing Don’t forget to publish your service!!!
37
Publishing You will need the Master key from the Manage Keys window
38
Appendix: ESP-8266 A cheap and relatively simple to use WiFi module Under 5$ in eBay Basic tutorial in course website For advanced users: fully programmable SoC (system-on-chip)
39
Appendix: ESP-8266 Comes with various baud rates. (Begin guessing with 115200) You can see the current baud rate using "AT+CIOBAUD?". (A very stupid command. why?) Setting a new baud rate: "AT+CIOBAUD=115200". Don’t use the Arduino to convert baud rates (i.e. 115200 to 9600) Uses strictly 3.3V. DO NOT CONNECT TO 5V!!! Current has some peaks, according to the Internet, the current might jump up to 1A (!!!), this is why we use a capacitor. TX/RX logic is also 3.3V. Works fine with Arduino Uno/Mega
40
Appendix: ESP-8266 ~470μF
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.