azure 236504 – winter 2015/16. what is cloud computing? imagine if tap water didn’t exist. every...

40
Azure 236504 – winter 2015/16

Upload: coleen-sullivan

Post on 19-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Azure236504 – winter 2015/16

Page 2: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 3: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 4: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 5: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Time-Sharing Systems

Cloud computing has its origins in the 1960s, as the time-sharing systems appeared.

Time sharing took advantage of the time theprocessor spent waiting for I/O, and allocated these slices of time to other users.

Source: Programming Windows Azure (Sriram Krisbnan)

Page 6: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 7: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Grid Computing VS Cloud ComputingThe 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 queuedCloud computing, on theother hand, is about lots of small allocation requests, with allocations happening in real time. Source: Programming Windows Azure (Sriram

Krisbnan)

Page 8: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Why Cloud?

• “Unlimited resources”

• Scale on demand

• #clients

• #services

• Out of the box infrastructure

• Redundant (geographical)

• Compatibility with different clients

• Less deployment management

Page 9: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 10: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 11: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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

Page 12: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

The Azure portal

• Azure control panel: https://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/

Page 13: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be
Page 14: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Mobile Service Software Stack

App Service

ControllerControllerProxy

JSON / XMLJSON / XML

HTTPHTTP

Client Cloud

Page 15: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

To Visual Studio!

• Preparing the solution

• You will need:

• Azure Mobile Service

Page 16: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

To Visual Studio!

• Preparing the solution

• You will need:

• A Client Project

• We will use WPF

• In order to supportWindows Phoneyou will needUniversal App

Page 17: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Adding the Azure Libraries

• Managed by NuGet

Page 18: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Adding the Azure Libraries

• Search for “Azure”

• Add:“Windows AzureMobile Services”and:“Windows AzureStorage”

Page 19: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Visual Studio Project Structure

Solution (*.sln)

Project – Client App Project – Cloud Service

class MyController : ApiController {...

}

class TodoItemController : TableController<TodoItem> {...

}

App Service

CtrlrCtrlrProxy

JSON / XMLJSO / XML

HTTPHTTP

Page 20: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Visual Studio Project Structure

Solution (*.sln)

Project – Client AppProject – Cloud

Service

public static MoblieServiceClient MobileService Defined in framework

class MyProxy { public static async Task<Result> DoWork(Request r) { return await App.MobileService.InvokeApiAsync<Result>(... r ...); }}

App Service

CtrlrCtrlrProxy

JSON / XMLJSON / XML

HTTPHTTP

Page 21: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Async

• The Async keyword makes it easy to write multi-threaded non-blocking calls

public async Task<int> ExampleMethodAsync(){ // . . . .}

string contents = await contentsTask;task<int> result = f(42);int x = await result;

Page 22: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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"}]}

App Service

CtrlrCtrlrProxy

JSON / XMLJSON / XML

HTTPHTTP

Page 23: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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

Page 24: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Naming Requirements

• In client project:

return await App.MobileService.InvokeApiAsync<MyReturnType , MyParamType>(“mycontroller/mymethod",

MyParamType p HttpMethod.Get, new Dictionary<string, string>() ...);

// 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<string, string>() ... – additional url// parameters

Page 25: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Other Constants

• In client project:

• In class App:public static MobileServiceClient MobileService = new MobileServiceClient("http://myService.azure-mobile.net/", “ApplicationKey");

Page 26: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Other Constants

• Find application keyhere:

Page 27: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Blob Storage

Page 28: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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 storage account objectfrom connection string

Page 29: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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 clientfor the current storage account

Page 30: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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.

Page 31: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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 :)

Page 32: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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.

Page 33: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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!

Page 34: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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!

Page 35: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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

Page 36: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Publishing• Don’t forget to publish your service!!!

Page 37: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Publishing• You will need the Master key from the Manage Keys window

Page 38: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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)

Page 39: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

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

Page 40: Azure 236504 – winter 2015/16. What Is Cloud Computing? Imagine if tap water didn’t exist. Every household would need to dig a well. Doing so would be

Appendix: ESP-8266

~470μF