Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cloud e Web con Windows AZURE e ASP.NET MVC 3 Speakers: Antimo Musone e Daniele Midi Facoltà

Similar presentations

Presentation on theme: "Cloud e Web con Windows AZURE e ASP.NET MVC 3 Speakers: Antimo Musone e Daniele Midi Facoltà"— Presentation transcript:

1 Cloud e Web con Windows AZURE e ASP.NET MVC 3 Speakers: Antimo Musone e Daniele Midi Facoltà di Ingegneria,Tor Vergata,12 Dicembre 2011

2 About We Antimo Musone Cloud Development Tour Owner Daniele Midi Web Development Tour Owner Web Team

3 Agenda Cloud Platform Why Cloud ? Windows Azure Hosting App Models Management Demo Hello World Windows Azure Storage Interoperability MVC 3 Web App MVC 3 in Azure Demo MVC3

4 START WITH : Cloud Antimo Musone Cloud Development Tour Owner

5 What is the cloud? An approach to computing thats about internet scale and connecting to a variety of devices and endpoints

6 Why Cloud? Customer Requirements : Efficency, Reliability Scalability, Agility Reduce IT Costs IT Consultants Dont must be IT warriors Can delegate IT Problems

7 Cloud Computing Patterns Usage Compute Time Average Inactivity Period On & off workloads (e.g. batch job) Compute Time Average Usage Unexpected/unplanned peak in demand Average Usage Compute Time Successful services needs to grow/scale Compute Time Average Usage Services with micro seasonality trends

8 Cloud Services Software-as-a-Service SaaS Platform-as-a-Service PaaS Infrastructure-as-a-Service IaaS

9 Caso Cloud: Il Censimento connessione in un solo giorno Carico di workload inaspettato In tilt dopo poche ore dal lancio Raddoppiata linfrastruttura IT in una sola Notte Infrastuttura Cloud : Telecom Italia

10 Windows Azure Platform

11 Windows Azure Platform : Layers Windows Azure Networking Red Dog Front End (RDFE) Compute Services Middleware Services Data Services

12 Windows Azure Platform Data Centers North America Region Europe Region Asia Pacific Region

13 Windows Azure Compute

14 Windows Azure Platform Components Horizontal View

15 Windows Azure Windows Azure is a foundation of Microsofts Cloud Platform for Developers Operating System for the Cloud Runs applications in the cloud Provides Storage Application Management Developer SDK Windows Azure ideal for applications needing Scalability Availability Fault Tolerance

16 Operating System Operating System VM Web Server Web Server Operating System Operating System VM DBMS 3) Choose image, then create and configure VM(s) for application 1) Choose image, then create VM for DBMS and configure DBMS IaaS Library VM Images Developer Application Load Balancer 5) Configure load balancer 6) Manage VMs and DBMS (e.g., deploying new OS images in VMs) 2) Provision database, then create tables and add data 4) Install application

17 PaaS Developer Application 2) Deploy application 1) Provision database, then create tables and add data Load Balancer 3) Manage Applications

18 Operating System Operating System VM Role Application Role Application Operating System Operating System VM DBMS PaaS - Azure Azure Developer Application Load Balancer 3) Install Other application 2) Deploy application 1) Provision database, then create tables and add data 4) Manage VM & Applications Other Application

19 Windows Azure in 1 Slide Desktop VS Tools WA SDK Storage Cluster MSFT Datacenters Developer Portal Compute Cluster … … Service Management Service API REST … Cloud VM Runtime API VM Setup User Code RDP

20 Azure Role : Scale Application Archetype

21 Azure Scale Applications: Layers Intelligent Network : Load Balancer Stateless Worker Machines : Worker Role Stateless Web Application : Web Role Async Work Shared Filesystem Partitioned RDBMS Key/Value Datastores Data /State Tier Queues

22 Azure Scale Applications: Roles Storage Tables LBLB LBLB Blobs Worker Service Worker Role Managed Interface Call Worker Role Managed Interface Call Web Site (ASPX, ASMX, WCF) Web Site (ASPX, ASMX, WCF) Web Site (ASPX, ASMX, WCF) Web Site (ASPX, ASMX, WCF) Web Role IIS as Host Web Role IIS as Host Queues Windows Azure Data Center LBLB LBLB LBLB LBLB The Internet via HTTP/TCP

23 Role Interface Azure Role: Application Box Role is an application container, that run inside Azure VM, through it we can provide Web / Service / Standalone Applications and also offers an interface to manage it

24 Services,Roles and Instances A Service is a packaged application for Azure, composed by one or more role Roles are defined in a Service Model May define one or more Roles per Service A role definition specifies VM size Communication Endpoints Local storage resources Etc… At runtime each Role will execute on one or more instances (up to 20 per subscription) A role instance is a set of code, configuration, and local data, deployed in a dedicated VM

25 Worker Role Patterns Queue Polling Worker Poll and Pop Messages within while(true) loop E.g. Map/Reduce pattern, background image processing Listening Worker Role Create TcpListener or WCF Service Host E.g. Run a.NET SMTP server or WCF Service External Process Worker Role OnStart or Run method executes Process.Start() Startup Task installs or executes background/foreground process E.g. Run a database server, web server, distributed cache

26 Web Role All features of a worker role + IIS 7 or 7.5 MVC 3, ASP.NET 3.5 SP1 or 4.0 – 64bit Hosts Webforms or MVC FastCGI applications (e.g. PHP) Multiple Websites Http(s) Web/Worker Hybrid Can optionally implement RoleEntryPoint

27 Service Definition Describes the shape of your Windows Azure Service Defines Roles Ports, Certificates Configuration Startup Tasks IIS Configuration

28 Service Configuration Supplies Runtime Values, can be updated any time through Portal or API Scale Config Settings Certificates to use, VHD etc.

29 VM Size in Windows Azure Windows Azure Supports Various VM Sizes Size set on Role in Service Definition Service can have multiple roles Balance of Performance per node vs. High Availability from multiple nodes Set in Service Model definition All instances of role will be of equal size SizeCPU CoresRAMLocal StorageCost ( $/Hour) Extra SmallShared768M20GB.05 Small11.7GB250GB.12 Medium23.5GB500GB.24 Large47GB1000GB.48 Extra large815GB2000GB.96

30 Windows Azure Platform Portal Web Access to : Supports multiple service administrators (co-admins) Enable and connect to Windows Azure instances using Remote Desktop Built on the Windows Azure Service Management APIs

31 Hello World by Windows Azure Demo

32 Windows Azure Storage

33 Storage in the Cloud Scalable, durable, and available Anywhere at anytime access Only pay for what the service uses Exposed via RESTful Web Services Use from anywhere on the internet User specified globally unique account name Can call these from any HTTP client (Flash, Silverlight ) Various storage abstractions Tables, Blobs, Queues, Drives 100TB per account, have two independent 512 bit shared secret keys

34 Blob Storage

35 Blob Storage Concepts Blob Container Account contoso images PIC01.JPG videos VID1.AVI / Pages/ Blocks Block/Page PIC02.JPG

36 Blob Details Main Web Service Operations PutBlob,GetBlob DeleteBlob,CopyBlob SnapshotBlob,LeaseBlob Associate Metadata with Blob Standard HTTP metadata/headers (Cache-Control, Content-Encoding, Content-Type, etc) Metadata is pairs, up to 8KB per blob Either as part of PutBlob or independently Blob always accessed by name Can include / or other delimeter in name e.g. / /myblobs/blob.jpg

37 Blob Containers Multiple Containers per Account Special $root container Blob Container A container holds a set of blobs Set access policies at the container level Associate Metadata with Container List the blobs in a container Including Blob Metadata and MD5 NO search/query. i.e. no WHERE MetadataValue = ? Blobs Throughput Effectively in Partition of 1 Target of 60MB/s per Blob

38 Table Storage

39 Table Storage Concepts EntityTableAccount contoso customers Name =… = … Name =… Add= … photos Photo ID =… Date =… Photo ID =… Date =…

40 Table Details Its not an RDBMS system but it s a container where we can serialize a collection of objects Table Operations : Create, Query, Delete Tables can have metadata Entities Operations : Insert,Delete Update Merge – Partial update Replace – Update entire entity Query Entity Group Transactions Multiple CUD Operations in a single atomic transaction

41 Entity Properties Entity can have up to 255 properties ( members of class ) Up to 1MB per entity Mandatory Properties for every entity PartitionKey & RowKey (only indexed properties) Uniquely identifies an entity Defines the sort order Timestamp Optimistic Concurrency. Exposed as an HTTP ETag No fixed schema for other properties No schema stored for a table Properties can be the standard types: String, binary, bool, DateTime, GUID, int, int64, and double

42 FirstLastBirthdate KimAkers2/2/1981 NancyAnderson3/15/1965 MarkHassallMay 1, 1976 Querying ?$filter=Last eq Akers

43 Queue Storage

44 Queue Storage Concepts Message Queue Account order processing customer ID order ID adventureworks

45 Loosely Coupled Workflow with Queue Enables workflow between roles Load work in a queue Producer can forget about message once it is in queue Many workers consume the queue For extreme throughput use multiple queues or multiple work items per message Queue Input Queue (Work Items)

46 Queue Details Simple asynchronous dispatch queue No limit to queue length subject to storage limit 8kb per message ListQueues - List queues in account Queue operations CreateQueue,DeleteQueue Get/Set Metadata Clear Messages Message operations PutMessage– Reads message and hides for time period GetMessages – Reads one or more messages and hides them PeekMessages – Reads one or more messages w/o hiding them DeleteMessage – Permanently deletes messages from queue

47 SQL AZURE Database

48 SQL Azure Extending SQL Server to the Cloud

49 SQL Azure Database Familiar SQL Server relational database model delivered as a service Support for existing APIs & tools Built for the cloud with high availability & fault tolerance Easily provision and manage databases across multiple datacenters SQL Azure provides logical server Gateway server that understands TDS protocol Looks like SQL Server to TDS Client Actual data stored on multiple backend data nodes Logical optimizations supported Indexes, Query plans etc.. Physical optimizations not supported File Groups, Partitions etc… Transparently manages physical storage

50 SQL Azure SQL Azure Use & Deployment : Web Portal () (API) Web Portal () (API) SQL Azure TDS SQL Azure TDS DB Script SQL Server Managment Custom Tool

51 SQL Azure Data Sync Geo-replication of SQL Azure data and spanning on-premises with cloud geo-replication sync between SQL Server and SQL Azure Builds on Sync Framework Sync data between SQL Azure, SQL Compact and SQL Server On-PremisesCloudOffline Clients

52 AZURE Interoperability

53 Development & Interoperability Microsoft & Partners provide development tools & sdk to design/develop Web Apps & Services on Azure Platform Windows Azure SDK & Training Kit : A step by step helper, provide a full developer local environment to develop and test Azure Apps Development Fabric: simulate in local Windows Azure SO Development Storage: : simulate in local Windows Azure Storage Not only tools for Microsoft Platform but also Windows Azure Team provide tools for Eclipse, Java and many other open source technology C / C++ Win32 VHD

54 Azure + Phone 1 / 2 Phone Connection Smart Marketplace Azure Services Scalability Common development tools Azure Key Word : Interoperability

55 Azure + Phone 2 / 2 Common development tools Azure Apps Development Tools & Interoperability with all mobile platforms Azure Datacenters

56 SWITCH TO : Web Daniele Midi Web Development Tour Owner

57 Coffee break (5 min)


59 Parleremo di... Pattern MVC MVC secondo Microsoft Gestione dei dati Web Apps per il Cloud


61 MVC : formulazione originale E un pattern architetturale che risolve il problema di disaccopiare la logica di interfaccia da quella di dominio. Model ViewController Observer

62 Model ViewController Model ViewController MVC adattato al Web (Model 2) Skinny Controller, Fat Model and Dumb View (RubyOnRails devs)

63 MVC secondo Microsoft BROWSER ROUTING ENGINE Controller Model View


65 Controller E una classe. Convention-over-configuration: per convenzione, la classe del Controller deve chiamarsi NomeControllerController –es.: AnnunciController Contiene la logica di interazione per un certo numero di pagine logicamente collegate –es.: AnnunciController potrebbe: visualizzare lelenco degli annunci vedere i dettagli di un annuncio aggiungere un nuovo annuncio

66 Action E un metodo di un Controller. Quando lutente richiede lesecuzione di una certa azione (visualizzare i dettagli di un annuncio, crearne uno nuovo, …) viene invocata la relativa Action. La Action esegue della logica applicativa e poi restituisce un oggetto ActionResult, che sarà utilizzato per mostrare i risultati allutente in una pagina (la View). ActionFilterActionActionResult

67 RICHIESTA HomeController Index () About () AnnunciController Index () Details (int id) Create () ?

68 Routing engine ROUTING ENGINE routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); AnnunciDetails12 CONTROLLERIDACTION AnnunciController.Details(12)

69 Request URL RoutingController ActionAction Result View Result MVC secondo Microsoft

70 DEMO: Creazione di unapplicazione Web con ASP.NET MVC

71 Model (anzi, ViewModel) Il Model in ASP.NET MVC fa da intermediario fra Controller e View –permette di tipizzare i dati scambiati fra Controller e View Si parla allora di ViewModel: –Classi create ad uso e consumo delle View –Classi completamente anemiche (solo attributi)

72 Validazione: Data Annotations Dato che i ViewModel nascono prettamente per tipizzare i dati scambiati con la view, possono essere usate anche per definire le regole di validazione e rendering della view che le consuma. In.NET possiamo indicare tali informazioni con dei semplici attributi chiamati Data Annotations:

73 View Loosely-Typed ASP.NET MVC < 3: ViewData –ACTION ViewData[Messaggio] = Benvenuto!; ViewData[Cliente] = new Customer(); –VIEW ASP.NET MVC 3: dynamic ViewBag + Razor –ACTION ViewBag.Messaggio = Benvenuto!; ViewBag.Cliente = new

74 View Strongly-Typed Inizia con una T –es.: una View che mostri i dettagli di una Sessione può iniziare con la Sessione È una normale pagina Web T è il ViewModel –un modello della View: raggruppa in una classe i dati che la View deve mostrare e gestire Vantaggi: –Intellisense –Controlli alla compilazione

75 Master Pages Definiscono lo scheletro dellinterfaccia utente. Sono composti di segnaposti per i contenuti delle varie pagine, che sono dei controlli ContentPlaceHolder. qui ci andrà la sidebar specifica di ogni pagina qui ci andrà il contenuto di ogni pagina MIOSITO.COM Home | About | Contatti

76 Model Binder: tipi primitivi MODEL BINDER QUERYSTRING URL PARAMETER HTML FORMS ACTION del CONTROLLER Libri public ActionResult Details(int id)

77 HTML FORM HTML => => => model.Eta) Model Binder: oggetti CLASSE PERSONA public string Nome { get; set; } public string Cognome { get; set; } public int Eta { get; set; } MODEL BINDER ACTION del CONTROLLER Persone public ActionResult Edit(Persona persona)

78 DEMO: ViewModel, Data Annotation e Strongly-Typed Views


80 Migliorare la User Experience ?

81 AJAX e Partial Rendering Controller View Form HTML

82 Controller View (dati) PartialView AJAX e Partial Rendering PartialView

83 jQuery Per accedere agli elementi del DOM posso utilizzare i selettori CSS $(a) restituisce tutti i tag A (link) Posso quindi eseguire delle funzioni JavaScript su tutti gli elementi. È possibile realizzare effetti ed animazioni in pochissime righe di JS, $(div).fadeIn(slow).animate({width, +50})

84 jQuery jQuery facilita anche la gestione degli eventi, rendendoli cross-browser $(document).ready(function() { alert(Sono pronto!); }); $(#bottone).click(function() { $(this).innerHtml=Cliccato!; });

85 DEMO: Enhancing User Experience: AJAX, Partial Views e jQuery


87 ASP.NET: MVC o WebForms? Vantaggi: +Testabilità completa (supporto a TDD) +Controllo completo sul accessibilità +URL SEO e user-friendly Svantaggi: –Controllo completo sul niente WebControls –Niente Postback e ViewState


89 Statelessness Load balancer round-robins requests in multi instance roles Follow web farm best practices –Do not store state on individual instances –Do not assume subsequent requests will hit the same instance Dont forget things like dynamically generated images loaded by a page All instances require the same MachineKey for hashing –Fabric uses same machine key for all instances in a role

90 AJAX and Windows Azure Client side calls may not return to the same instance the original page came from AJAX calls must be stateless –Dont generate a page and leave state on the server to call via AJAX later

91 Windows Azure Session State Windows Azure Load Balancer uses round-robin allocation. Session state must persist to client or storage on every request

92 Solving Session State Persist to Storage via Session State Provider –Windows Azure AppFabric Caching –3 rd party distributed cache (e.g. MemCached) –SQL Azure –Windows Azure Storage –Custom Persist to Client –Use cookies performance issues

93 Windows Azure AppFabric Caching Using Windows Azure AppFabric Caching as the session store In-memory, distributed cache Based on Windows Server AppFabric Caching Used the Microsoft.Web.DistributedCache assembly found in the SDK Enable ASP.NET 4 Session Compression Currently available in AppFabric LABS Portal as CTP

94 AppFabric Caching Session State

95 SQL Server Session State Use SQL Azure as backing store Round trip to database twice per request –Read at request start –Write at request end Enable ASP.NET 4 Session Compression Scale out across multiple DBs –Use session state partitioning – SQL Azure is competitive on cost basis

96 SQL Azure Session State Session state stored using SQL Server Session State Provider and session state partitioning resolve partitionresolve partition

97 Windows Azure Storage Providers Sample ASP.NET Providers (Session, Membership, Role etc…) Sample Code Uses Blob + Table Storage Several storage transactions per request Enable ASP.NET 4 Session Compression Sample Provider should be treated as a starting point only.

98 Cookies Serialize and Encrypt state into cookie Possible to implement as Session State Provider Cookies add significant performance overhead Cookies sent with every request to domain –Use alternative host header to serve images, … –Use Windows Azure Storage for static content

99 DNS All services get a * address – –TTL is 10 seconds Standard approach is to CNAME to * –Requires two DNS lookups –Limited caching due to low TTL Officially, Windows Azure do not support the use of A records IP Address for deployment is fixed for lifetime of that slot

100 High Performance DNS Approach Create service, deploy to staging slot Resolve IP for Create A Record for – –


102 Full IIS You can choose to deploy to Full IIS; no longer using required to use Hosted Web Core (HWC) Differences: –In Full IIS, the RoleEntryPoint runs under WaIISHost.exe while the web site runs under the normal IIS w3wp.exe process. –Support for running multiple websites –Load any IIS module Going to make migrating existing IIS-based applications a lot easier

103 Multi-Tenancy resolve tenant by examining host header

104 Web Deploy IIS Web Deployment Tool Simplifies the migration, management, and deployment of IIS Web servers, Web applications, and Web sites Youll be able to do web deploy using standard IIS7 publishing from Visual Studio Will not require you to deploy an entire package Warning: use for development purposes only


106 File Upload ASP.NET File Upload Control uses ASP.NET temporary directory to buffer files –Temp path cannot be changed to Local Resource or Windows Azure Drive Windows Azure Compute roles have 100MB of root disk space Problems arise –Uploading large files (~100MB) –Multiple users uploading concurrently (10 users uploading 10MB files)

107 File Upload Solutions Upload direct to Blob storage using Silverlight –Provide a Shared Access Signature to Silverlight control –Upload blocks direct to storage [] Use 3rd Party Control Implement a custom IHttpHandler to receive file and buffer to disk

108 Takeaways ASP.NET In Windows Azure –Broad support for ASP.NET Features –Must understand and architect for scale out Advanced Techniques –SaaS Applications using Virtual Path Providers and Host header checking Challenges

109 Creazione di unapplicazione Web con ASP.NET MVC + Azure Demo

110 Creazione di unapplicazione Web con ASP.NET MVC Demo


112 Questions

113 Microsoft Logo here Microsoft Logo Tagline here IMAGINE CUP 2012

114 Microsoft Logo here Microsoft Logo Tagline here IMAGINE A WORLD... The most important student technology competition!Lets join to thousands of students from around the world who are stepping up to the challenge of global change. Choose from three team competitions Software Design, Game Design: Xbox/Windows, and Game Design: Phone or take on the IT Challenge.

115 OVERVIEW The Game Design: Phone competition is an excellent opportunity to learn the art of mobile video game design! The IT Challenge is an individual challenge for students around the world who have the nterest, and technical knowledge to design infrastructures. The structure of the game is entirely up to you! The goal :Creatively using technology. The Software Design Competition is all about creating real-world applications that can help make the world a better place.

116 Microsoft Logo here Microsoft Logo Tagline here INSPIRATION Need a Litte Inspiration? Get motivated by one of the eight United Nations Millennium Development Goals: the Imagine Cup offers these ambitious challenges as a guide to promote change all around the world. Game Malaria Wars based on Windows for Xbox that improves knowledge about Malaria, Software Design project Brain which allow children, who had their elementary education interrupted, to continue learning and G7oups a Windows Phone 7 based application with a clear goal to improve in a creative way the education of guysUnited Nations Millennium Development Goals More at Imagine stories

117 STEP UP THE CHALLENGE Check out Form your Team Make new Friends, compete & change the World! Next year you could be on Finals!!


119 Vinci con Windows Phone Premi per oltre euro complessivi in buoni acquisto spendibili online presso Media World. tra estrazioni bisettimanali e premi finali


Download ppt "Cloud e Web con Windows AZURE e ASP.NET MVC 3 Speakers: Antimo Musone e Daniele Midi Facoltà"

Similar presentations

Ads by Google