Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cloud e Web con Windows AZURE e ASP.NET MVC 3

Similar presentations


Presentation on theme: "Cloud e Web con Windows AZURE e ASP.NET MVC 3"— Presentation transcript:

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

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

3 Agenda Cloud Platform Windows Azure Demo Why Cloud ? Hosting
App Models Management Demo Hello World 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 that’s about internet scale and connecting to a variety of devices and endpoints

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

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

8 Cloud Services “IaaS” “PaaS” “SaaS” host build consume
Software-as-a-Service consume “SaaS” Platform-as-a-Service build “PaaS” Infrastructure-as-a-Service host “IaaS” Slide Objectives: Explain the three established terms in the industry for cloud services Speaking Points: With this in mind, it’s important to understand how to talk about our Cloud Services offerings. There is a lot of confusion in the industry when it comes to the cloud. It’s important that you understand both what is happening in the industry and how we think about the cloud. This is the most commonly used taxonomy for differentiating between types of cloud services. The industry has defined three categories of services: IaaS – a set of infrastructure level capabilities such as an operating system, network connectivity, etc. that are delivered as pay for use services and can be used to host applications. PaaS – higher level sets of functionality that are delivered as consumable services for developers who are building applications. PaaS is about abstracting developers from the underlying infrastructure to enable applications to quickly be composed. SaaS – applications that are delivered using a service delivery model where organizations can simply consume and use the application. Typically an organization would pay for the use of the application or the application could be monetized through ad revenue. It is important to note that these 3 types of services may exist independently of one another or combined with one another. SaaS offerings needn’t be developed upon PaaS offerings although solutions built on PaaS offerings are often delivered as SaaS. PaaS offerings also needn’t expose IaaS and there’s more to PaaS than just running platforms on IaaS.

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

10 Windows Azure Platform
Scalable compute and storage Automated service management Familiar tools, technologies, languages Relational storage for the cloud Consistent development model Automated database management Connect existing apps to the cloud Connect through network boundaries Easily control authorization to apps

11 Windows Azure Platform : Layers
Middleware Services AppFabric Caching AppFabric Access Control AppFabric Service Bus SQL Azure Windows Azure Storage Windows Azure CDN Data Services “Red Dog” Front End (RDFE) Compute Services Fabric Controller Windows Azure Networking

12 Windows Azure Platform Data Centers
North America Region Europe Region Asia Pacific Region N. Europe Slide Objective Understand that Microsoft has a long history in running data centres and online applications. Bing, Live, Hotmail etc…. Understand the huge amount of innovation going on at the data center level Speaking Points: Microsoft is one of the largest operators of datacenters in the world Years of Experience Large scale trustworthy environments Driving for cost and environmental efficiently Windows Azure runs in 3 regions and 6 datacenters today Data center innovation is driving improved reliability and efficiency PUE = Power Usage Effectiveness = Total Facility power/IT Systems Power = Indication of efficiency of DC Under 1.8 is very good, modern cloud DCs approaching 1.2 Multi-billion dollar datacenter investment 700,000+ square foot Chicago and the 300,000+ square foot Dublin, Ireland data centers Microsoft cloud services provide the reliability and security you expect for your business: 99.9% uptime SLA, 24/7 support. Microsoft understands the needs of businesses with respect to security, data privacy, compliance and risk management, and identity and access control. Microsoft datacenters are ISO 27001:2005 accredited, with SAS 70 Type I and Type II attestations. Notes: N. Central – U.S. W. Europe S. Central – U.S. E. Asia S.E. Asia 6 datacenters across 3 continents Simply select your data center of choice when deploying an application

13 Windows Azure Compute

14 Windows Azure Platform
Components Horizontal View Speaking Points: I suspect most if not all of you in this room are familiar with the Windows Azure Platform today. Today the platform consists of a set of foundational services SQL Azure relational database AppFabric provides services that can be used by any apps – hosted in Windows Azure, on-premises, or hosted in another environment. Questions: How many of you are building applications for Windows Azure? How many are using SQL Azure? How many are using the Access Control service today? The Service Bus? Notes: Windows Azure Story We are building an open platform to run your applications in the cloud. Your apps are .NET, Java, PHP, etc. We love everyone. We are going to help you migrate your existing apps to the cloud. The cloud platform is the future. Enables scale, self-service, lowers friction, etc. We provide the best cloud platform for building new apps. (aka n-tier, web services, etc.) Virtual Network Compute Storage

15 Windows Azure Windows Azure is a foundation of Microsoft’s 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 This should be a recap as this session will dig deeper into the services.

16 IaaS Developer Library VM Images Operating System VM Web Server
TechReady12 3/29/2017 IaaS Developer 6) Manage VMs and DBMS (e.g., deploying new OS images in VMs) 1) Choose image, then create VM for DBMS and configure DBMS 2) Provision database, then create tables and add data 5) Configure load balancer 3) Choose image, then create and configure VM(s) for application 4) Install application Library VM Images Operating System VM Web Server Operating System VM DBMS Application Load Balancer © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

17 1) Provision database, then create tables and add data
TechReady12 3/29/2017 PaaS Developer 3) Manage Applications 1) Provision database, then create tables and add data 2) Deploy application Application Web Server Load Balancer DBMS Operating System Operating System Operating System VM VM © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

18 PaaS - Azure Azure Developer Load Balancer Operating System VM Role
TechReady12 3/29/2017 PaaS - Azure Azure Developer 3) Install Other application 1) Provision database, then create tables and add data 2) Deploy application 4) Manage VM & Applications Load Balancer Operating System VM Role Application Application Operating System VM DBMS Other Application © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

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

20 Azure Role : Scale Application Archetype

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

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

23 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 Methods Events Status OnStart Role Lifetime StatusCheck Busy Requests Routed Fabric Calls Slide Objective Understand the lifecycle of a Windows Azure role Understand the methods that can be overridden in RoleEntryPoint Understand the events that are raised by role instances when their status is changing Speaker Notes Roles will typically extend RoleEntryPoint The fabric calls RoleEntryPoint methods as it starts and stops a role WaWorkerHost process is started. Worker Role assembly is loaded and surfed for a class that derives from RoleEntryPoint.  This class is instantiated. RoleEntryPoint.OnStart() is called. RoleEntryPoint.Run() is called.  If the RoleEntryPoint.Run() method exits, the RoleEntryPoint.OnStop() method is called . WaWorkerHost process is stopped. The role will recycle and startup again. As a role changes state it will raise the StatusCheck event. A status of Busy will mean the load balancer will not route requests to the instance. Note Role Interface Run StatusCheck Ready OnStop StatusCheck Busy Stopping

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 Slide Objective Understand the difference between Roles and Instances Speaker Notes The Service model defines the shape of a service- the Roles it will have endpoints it will listen on Types of VMs that will be run At runtime each Role will run at a given scale Specifically each role will be deployed onto and executed on one or more VMs A VM runs a single role Notes Notes on the various security roles involved in running a Windows Azure account

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 Slide Objective Understand the 3 common patterns of worker roles Speaker Notes Pattern 1 – Polling Worker role polls a Queue Pops message Performs work Polls queue again Pattern 2 Worker listens for inbound TCP request Can implement with Raw TcpListeners or use WCF or use Hosted Web Core Pattern 3 Run a 3rd party process When the role starts up or runs use a Process.Start() call to run a standard windows executable E.g. Running a database server Notes

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 Slide Objective Understand how a Web Role extends the standard worker role Speaker Notes A web role takes all the capabilities and semantics of a worker role and adds the IIS Hostable Web Core Web Roles run ASP.NET websites- they do this by using the IIS hostage web core. pretty much anything that will work in a standard IIS ASP.NET Web Site should work in Windows Azure. At MIX09, we additionally added support for IIS7’s FastCGI capability. As a note, any files that are part of a asp.net project on windows azure are READ ONLY! If you need to be able to change the contents of files: User Blob Storage If its configuration, use the service model files – which can be changed at runtime. Inbound protocols are http(s) – outbound protocols are any TCP connection but NOT UDP. Notes

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
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 Slide Objective To understand how and why to change the VM Size for a Windows Azure role Slide Notes When you create your service model, you can specify the size of the virtual machine (VM) to which to deploy instances of your role, depending on its resource requirements. The size of the VM determines the number of CPU cores the memory capacity the local file system size allocated to a running instance Each physical machine in Windows Azure contains 8 processor cores. You need to specify an XL instance to reserve an entire machine Network is shared but burstable Can burst beyond your 1/8th allocation when using a small VM May be limited to just your allocation For guaranteed high network throughput use an XL VM Not Size CPU Cores RAM Local Storage Cost ( $/Hour) Extra Small Shared 768M 20GB .05 Small 1 1.7GB 250GB .12 Medium 2 3.5GB 500GB .24 Large 4 7GB 1000GB .48 Extra large 8 15GB 2000GB .96

30 Windows Azure Platform Portal
Web Access to : https://windows.azure.com Supports multiple service administrators (co-admins) Enable and connect to Windows Azure instances using Remote Desktop Built on the Windows Azure Service Management APIs Speaking Points:

31 Hello World by Windows Azure
Demo Hello World by Windows Azure

32 Windows Azure Storage

33 Windows Azure Storage 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 This should be a recap as this session will dig deeper into the services.

34 Blob Storage BLOB : LA SOSTANZA ANCHE SENZA FORMA
Personaggio degli x-men e presente in uno degli ultimi film come wolverine e le sue origini Blob Storage

35 Blob Storage Concepts Account Container Blob Pages/ Blocks
Account Container Blob Pages/ Blocks PIC01.JPG Slide Objectives Understand the hierarchy of Blob storage Speaker Notes The Blob service provides storage for entities, such as binary files and text files. The REST API for the Blob service exposes two resources: Containers Blobs. A container is a set of blobs; every blob must belong to a container. The Blob service defines two types of blobs: Block blobs, which are optimized for streaming. Page blobs, which are optimized for random read/write operations and which provide the ability to write to a range of bytes in a blob. Blobs can be read by calling the Get Blob operation. A client may read the entire blob, or an arbitrary range of bytes. Block blobs less than or equal to 64 MB in size can be uploaded by calling the Put Blob operation. Block blobs larger than 64 MB must be uploaded as a set of blocks, each of which must be less than or equal to 4 MB in size. Page blobs are created and initialized with a maximum size with a call to Put Blob. To write content to a page blob, you call the Put Page operation. The maximum size currently supported for a page blob is 1 TB. Notes Using the REST API for the Blob service, developers can create a hierarchical namespace similar to a file system. Blob names may encode a hierarchy by using a configurable path separator. For example, the blob names MyGroup/MyBlob1 and MyGroup/MyBlob2 imply a virtual level of organization for blobs. The enumeration operation for blobs supports traversing the virtual hierarchy in a manner similar to that of a file system, so that you can return a set of blobs that are organized beneath a group. For example, you can enumerate all blobs organized under MyGroup/. images Block/Page PIC02.JPG contoso Block/Page videos VID1.AVI

36 Blob Details Main Web Service Operations Associate Metadata with Blob
PutBlob,GetBlob DeleteBlob,CopyBlob SnapshotBlob ,LeaseBlob Associate Metadata with Blob Standard HTTP metadata/headers (Cache-Control, Content-Encoding, Content-Type, etc) Metadata is <name, value> 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. /<container>/myblobs/blob.jpg Slide Objectives Understand the hierarchy of Blob storage Speaker Notes Put Blob - Creates a new blob or replaces an existing blob within a container. Get Blob - Reads or downloads a blob from the system, including its metadata and properties. Delete Blob - Deletes a blob Copy Blob - Copies a source blob to a destination blob within the same storage account. SnapShot Blob - The Snapshot Blob operation creates a read-only snapshot of a blob. Lease Blob - Establishes an exclusive one-minute write lock on a blob. To write to a locked blob, a client must provide a lease ID. Using the REST API for the Blob service, developers can create a hierarchical namespace similar to a file system. Blob names may encode a hierarchy by using a configurable path separator. For example, the blob names MyGroup/MyBlob1 and MyGroup/MyBlob2 imply a virtual level of organization for blobs. The enumeration operation for blobs supports traversing the virtual hierarchy in a manner similar to that of a file system, so that you can return a set of blobs that are organized beneath a group. For example, you can enumerate all blobs organized under MyGroup/. Notes The Blob service provides storage for entities, such as binary files and text files. The REST API for the Blob service exposes two resources: containers and blobs. A container is a set of blobs; every blob must belong to a container. The Blob service defines two types of blobs: Block blobs, which are optimized for streaming. This type of blob is the only blob type available with versions prior to Page blobs, which are optimized for random read/write operations and which provide the ability to write to a range of bytes in a blob. Page blobs are available only with version Containers and blobs support user-defined metadata in the form of name-value pairs specified as headers on a request operation. Using the REST API for the Blob service, developers can create a hierarchical namespace similar to a file system. Blob names may encode a hierarchy by using a configurable path separator. For example, the blob names MyGroup/MyBlob1 and MyGroup/MyBlob2 imply a virtual level of organization for blobs. The enumeration operation for blobs supports traversing the virtual hierarchy in a manner similar to that of a file system, so that you can return a set of blobs that are organized beneath a group. For example, you can enumerate all blobs organized under MyGroup/. A block blob may be created in one of two ways. Block blobs less than or equal to 64 MB in size can be uploaded by calling the Put Blob operation. Block blobs larger than 64 MB must be uploaded as a set of blocks, each of which must be less than or equal to 4 MB in size. A set of successfully uploaded blocks can be assembled in a specified order into a single contiguous blob by calling Put Block List. The maximum size currently supported for a block blob is 200 GB. Page blobs are created and initialized with a maximum size with a call to Put Blob. To write content to a page blob, you call the Put Page operation. The maximum size currently supported for a page blob is 1 TB. Blobs support conditional update operations that may be useful for concurrency control and efficient uploading. Blobs can be read by calling the Get Blob operation. A client may read the entire blob, or an arbitrary range of bytes. For the Blob service API reference, see Blob Service API.

37 Blob Containers Multiple Containers per Account Blob Container
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 Slide Objective Understand containers Speaker Notes Account can contain unlimited number of containers Root container useful when serving Silverlight and flash out of Blob storage. May need to store Cross domain access policy files in root of the domain Metadata is up to 8KB of name value pairs per container Notes A root container serves as a default container for your storage account. A storage account may have one root container. The root container must be explicitly created and must be named $root. A blob stored in the root container may be addressed without referencing the root container name, so that a blob can be addressed at the top level of the storage account hierarchy. For example, you can now reference a blob that resides in the root container in the following manner:

38 Table Storage

39 Table Storage Concepts
Account Table Entity Name =… = … customers Slide Objectives Understand Tables Speaker Notes The Table service provides structured storage in the form of tables. The Table service supports a REST API that is compliant with the ADO.NET Data Services REST API. Developers may also use the .NET Client Library for ADO.NET Data Services to access the Table service. Notes Name =… Add= … contoso Photo ID =… Date =… photos Photo ID =… Date =…

40 Table Details It’s 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 Slide Objectives Understand Tables Speaker Notes Within a storage account, a developer may create named tables. Tables store data as entities. An entity is a collection of named properties and their values, similar to a row. Tables are partitioned to support load balancing across storage nodes. Each table has as its first property a partition key that specifies the partition an entity belongs to. The second property is a row key that identifies an entity within a given partition. The combination of the partition key and the row key forms a primary key that identifies each entity uniquely within the table. The Table service does not enforce any schema. A developer may choose to implement and enforce a schema on the client side Notes

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 Slide Objectives Understand Tables and Entities Speaker Notes Tables store data as entities. An entity is a collection of named properties and their values, similar to a row- not an RDBMS though Tables are partitioned to support load balancing across storage nodes. Each table has as its first property a partition key that specifies the partition an entity belongs to. The second property is a row key that identifies an entity within a given partition. The combination of the partition key and the row key forms a primary key that identifies each entity uniquely within the table. The Table service does not enforce any schema. A developer may choose to implement and enforce a schema on the client side Notes

42 Querying ?$filter=Last eq ‘Akers’
?$filter=Last eq ‘Akers’ Slide Objectives Understand The Basic Query Syntax Speaker Notes Tables store data as entities. Querying is per the ADO.NET Data Services spec Should endeavour to always include the Partition key to limit scope of query- partitions always served by a single storage node Notes First Last Birthdate Kim Akers 2/2/1981 Nancy Anderson 3/15/1965 Mark Hassall May 1, 1976

43 Queue Storage

44 Queue Storage Concepts
Account Queue Message customer ID order ID Slide Objectives Understand Queues Speaker Notes The Queue service provides reliable, persistent messaging within and between services. The REST API for the Queue service exposes two resources: queues and messages. Notes adventureworks order processing customer ID order ID

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 Worker Role Web Role Slide Objectives Understand the Value of Queues Speaker Notes Queues allow the apparent perf of app to be improved Work can be buffered in queue and performed later Allows simple async comms between roles More on this Day 2 Notes Worker Role Queue Input Queue (Work Items) Web Role Worker Role Web Role Worker Role

46 Queue Details Simple asynchronous dispatch queue Queue operations
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 Slide Objectives Understand Queues in Detail Speaker Notes The Queue service provides reliable, persistent messaging within and between services. The REST API for the Queue service exposes two resources: Queues messages. Queues support user-defined metadata in the form of name-value pairs specified as headers on a request operation. Each storage account may have an unlimited number of message queues that are named uniquely within the account. Each message queue may contain an unlimited number of messages. The maximum size for a message is limited to 8 KB. When a message is read from the queue, the consumer is expected to process the message and then delete it. After the message is read, it is made invisible to other consumers for a specified interval. If the message has not yet been deleted at the time the interval expires, its visibility is restored, so that another consumer may process it Notes

47 SQL AZURE Database

48 SQL Azure Database Reporting Data Sync
Extending SQL Server to the Cloud Slide Objectives: Introduction to SQL Azure Explain SQL Azure Database Indicate that other services are coming in the future Speaking Points: SQL Azure provides Microsoft SQL Server in the cloud Broadly compatible with online SQL Server In the future other services are planned DataSync- to sync data between On premise and the cloud Notes Cloud-based relational database service built on SQL Server® technologies. It provides a highly available, scalable, multi-tenant database service hosted by Microsoft in the cloud. SQL Azure Database helps to ease provisioning and deployment of multiple databases. Developers do not have to install, setup, patch or manage any software. High availability and fault tolerance is built-in and no physical administration is required. Database Reporting Data Sync

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 Slide Objectives: Understand the key differentiators of SQL Azure Understand where a user has control and where the cloud runs things Speaking Points: SQL Azure provides highly available SQL Server. Appears to be a SQL Server to the client. In reality is 3 transitionally consistent copies of the database that are fronted by a Gateway that appears to be a SQL server Simple to provision- create a logical server in the Portal, execute a create DB Command to create a new database Can add and remove DBs easily from application to scale up and down Customers look after logical optimizations like indexes SQL Azure manages the physical database No need to install or patch software or other physical administration Automatic high availability and fault tolerance Simple provisioning and deployment of multiple databases Scale databases up or down based on business needs Multi-tenant Integration with SQL Server and tooling including Visual Studio Support for T-SQL based familiar relational database model Notes

50 SQL Azure SQL Azure Use & Deployment : Web Portal (API)
DB Script SQL Server Managment SQL Azure TDS 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-Premises Cloud Offline 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 Azure Azure Key Word : Interoperability
Connection Smart Marketplace Azure Key Word : Interoperability Common development tools Azure Services Scalability

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

56 SWITCH TO : Web Daniele Midi Web Development Tour Owner

57 Coffee break (5 min)

58 patternS: mvc originale, mvc model2, Asp.net mvc.

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

60 patternS: mvc originale, mvc model2, Asp.net mvc.

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

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

63 MVC secondo Microsoft Model ROUTING ENGINE BROWSER Controller View 3 4
1 2 5 View 6

64 ATTORI: controller, action, routing, viewmodel, view, modelbinder.

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 l’elenco degli annunci vedere i dettagli di un annuncio aggiungere un nuovo annuncio

66 Action ActionFilter Action ActionResult
E’ un metodo di un Controller. Quando l’utente richiede l’esecuzione 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 all’utente in una “pagina” (la View). ActionFilter Action ActionResult

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

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

69 MVC secondo Microsoft Request Result URL Routing Controller Action
Action Result View Result

70 DEMO: Creazione di un’applicazione 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 ViewBag.Cliente = new Customer();
ASP.NET MVC < 3: ViewData ACTION ViewData[“Messaggio”] = “Benvenuto!”; ViewData[“Cliente”] = new Customer(); VIEW <%: ViewData[“Messaggio”] %> <%: (ViewData[“Cliente”] as Cliente).Nome %> ASP.NET MVC 3: dynamic ViewBag + Razor ViewBag.Messaggio = “Benvenuto!”; ViewBag.Cliente = new Customer(); @ViewBag.Messaggio @ViewBag.Cliente.Nome

74 View Strongly-Typed Inizia con una dichiarazione @model 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 MIOSITO.COM
Definiscono lo “scheletro” dell’interfaccia utente. Sono composti di “segnaposti” per i contenuti delle varie pagine, che sono dei controlli ContentPlaceHolder. MIOSITO.COM Home | About | Contatti qui ci andrà la sidebar specifica di ogni pagina qui ci andrà il contenuto di ogni pagina

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

77 ACTION del CONTROLLER “Persone”
Model Binder: oggetti CLASSE “PERSONA” public string Nome { get; set; } public string Cognome public int Eta HTML FORM <form action=“/Persone/Edit”> <input type=“text” name=“persona.Nome” /> <input type=“text” name=“persona.Cognome” /> <input type=“text” name=“persona.Eta” /> </form> HTML FORM <form action=“/Persone/Edit”> @Html.TextBoxFor(model => model.Nome) @Html.TextBoxFor(model => model.Cognome) @Html.TextBoxFor(model => model.Eta) </form> ACTION del CONTROLLER “Persone” public ActionResult Edit(Persona persona) MODEL BINDER

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

79 USER EXPERIENCE: AJAX, Partial rendering, JQUERY.

80 Migliorare la User Experience
?

81 AJAX e Partial Rendering
View Form HTML Controller

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

83 restituisce tutti i tag “A” (link)
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 $(document).ready(function() { alert(“Sono pronto!”); });
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

86 Mvc vs webforms: fate la vostra scelta . (giusta.)

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

88 ASP.NET MVC per WINDOWS AZURE: beh, CHE PROBLEMA C’è?

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 Don’t 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 Slide Objective Recap on statelessness Reinforces nature of stateless servers in the context of web requests Speaking Notes Windows Azure uses load balancers that round robin requests to each instance When running in Windows Azure with multiple instances there is no guarantee that subsequent requests will hit the same instance Some things to remember here Subsequent requests may not always be obvious e.g. Think of an ASP.NET page that includes an image url that is served by an HTTP Handler Can’t assume that the image will be loaded form the same instances that served the original ASP.NET page Which leads on to talking about AJAX… Notes

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 Don’t generate a page and leave state on the server to call via AJAX later Slide Objective Reinforce the need to think about statelessness when working with AJAX Speaking Notes AJAX requests (e.g. JQuery calls to the server) may not go back to the instance that originally served the page Can’t leave ‘nuggets’ of state inside a web role with the intention of fetching it via APAX later Can push the state back into storage Either store it up direct out of storage (e.g. grab an XML block using a Shared Access Signature) May be better to use a Data Island in the original document in this case though Push it into storage and re-fetch in web role when AJAX call arrives ASP.NET Ajax requires a common machine key in web farm environments. Windows Azure is pre-configured for this- all the instances in a role will have the exact same machine key Can modify the machine key if you need to from code There is NO support for sticky sessions. Notes Changing machine key in code

91 Windows Azure Session State
Windows Azure Load Balancer uses round-robin allocation. Session state must persist to client or storage on every request session[“foo”] = 1; session[“foo”] = 2; Slide Objective Explains the operation of Session state in Windows Azure multi instance roles Speaking Notes Must move session state off the Web Role instances In this animation First request hits one instance Subsequent request hits another instance At the end of the animation the value of Foo is hard to determine. Is it 1, 2 or null? Will depend on which server the LB routes our request to Notes LB What is the value of session[“foo”]? SQL Azure Windows Azure Storage

92 Solving Session State Persist to Storage via Session State Provider
Windows Azure AppFabric Caching 3rd party distributed cache (e.g. MemCached) SQL Azure Windows Azure Storage Custom Persist to Client Use cookies  performance issues Slide Objective Explains the implementation of Session state in Windows Azure multi instance roles Speaking Notes Must move session state off the Web Role instances Move it into storage of some sort Windows Azure AppFabrich caching is the obvious choice Distributed, in-memory caching running in Windows Azure SQL Azure and Windows Azure storage are are additional examples Which is best will depend on the nature of the application load (due to the transaction charge for Windows Azure Storage) SQL Server. Will need to implement your own session cleanup code for SQL Azure which means you will probably need a custom session state provider The Windows Azure Storage Provider is SAMPLE CODE ONLY. It should not be relied on for production apps without significant modification Another option is to push the state to the client. Could potentially write a custom session state provider that always persists the state to a cookie This WILL have performance impact Could also use a custom or 3rd party distributed cache to store session state in a shared everything (fully replicated) configuration (e.g. memcached) Notes 3rd party Sql Azure session state provider Cookie size performance impact

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
Session state stored using Windows Azure AppFabric Caching and an out-of-the-box session state provider session[“foo”] = 1; session[“foo”] = 2; LB What is the value of session[“foo”]? AppFabric Caching

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 Slide Objective Explains the use of SQL Azure as a backing store Speaking Notes The Out of the Box SQL Server ASP.NET Session State mechanism is not suitable for Azure Relies on SQL Server Agent which is not available in SQL Azure Will need to implement a custom session state provider Store and retrieve state Cleanup Will probably want to use some sort of partitioning mechanism. Partitioning is a feature in the ASP.NET provider interfaces… so just need to implement the mechanism to reolsve the partition For more on partitioning see the day 2 storage strategies session SQL Azure is cost competitive Particularly in high and consistent load scenarios SQL Azure does not have the storage transaction charge SQL Session state generally only requires a small amount of storage Scale out across 1GB SQL Azure databases Notes 3rd party Sql Azure session state provider

96 SQL Azure Session State
Session state stored using SQL Server Session State Provider and session state partitioning session[“foo”] = 1; session[“foo”] = 2; Slide Objective Explains the operation of Session state in Windows Azure multi instance roles using partitioned SQL Azure as the mechanism Speaking Notes In this approach 3 x 1GB SQL Azure databases are used The appropriate partition is resolved by the Web Role and the session state is pushed to the correct database At the end of this process the session state value will be reliably read as being 2 Notes LB resolve partition What is the value of session[“foo”]? SQL Azure 3 x 1GB Databases

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. Slide Objective Provides a pointer to and discussion of the Windows Azure Storage providers Speaking Notes Windows Azure storage also makes an ideal location for session state The sample providers available on MSDN should be treated as a starting point only Notes

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 Slide Objective Discusses the approach of using Cookies to hold state. Speaking Notes Avoiding session state and simply pushing the state to the client as a cookie Could implement a session state provider on top of this approach Avoids the need to roundtrip to/from the database or storage each request Worth comparing the perf difference between the two approaches Don’t forget that cookies are sent back and forth with every HTTP request- e.g. if you serve images from your Web Role you will end up with cookies being sent Can use an alternative Host header in order to avoid this Can also use Windows Azure Blob storage to serve images and other static content. Notes

99 DNS All services get a *.cloudapp.net address
myservicename.cloudapp.net TTL is 10 seconds Standard approach is to CNAME to *.cloudapp.net 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 Slide Objective Discusses managing DNS entries for Windows Azure Web Role hosted sites Speaking Notes By default all sites get a *.cloudapp.net URL Should avoid using this for anything other than testing your site 10 second TTL on the DNS entry means it will do a full DNS lookup an almost every request Runs the risk of leaking data from cookies etc due to many sites using the same cloudapp.net domain The standard approach of using a Cname has a number of limitations It will require two DNS lookups One to lookup the Cname resolving it to foo.cloudapp.net Another to reoslve foo.cloudapp.net to the actual IP address The low TTL on the cloudapp.net domain means there will be unnecessary lookups It is not possible to Cname the root of a domain e.g. you may want to use which will require an A record resolving to an IP address The nice thing is that for the lifetime of your deployment you actually have a fixed IP address. Let’s see how we can take advantage of this Notes Good thread

100 High Performance DNS Approach
Create service, deploy to staging slot Resolve IP for yourapp.cloudapp.net Create A Record for yourapp.com Slide Objective Discusses managing DNS entries for Windows Azure Web Role hosted sites Speaking Notes For all intents and purposes Windows Azure IPs are fixed. They are fixed for the lifetime of a deployment They remain fixed even when you VIP Swap Therefore you can comfortably create A records against the IP address for your production slot. This will save you the double lookup for a CName record. It will also allow you to create an entry for the root of a domain So the approach for high performance DNS is as follows Create your hosted service Deploy into the production slot nslookup myapp.cloudapp.net to get the IP Create A records for and myapp.com with a decent length TTL Run your service doing rolling upgrades and VIP swaps till your hearts content If you need to delete your deployment (e.g. to reconfigure external endpoints) then you should; lower the TTL on the A records wait till the old TTL expires create a new service deploy to prod slot NSLookup swap the IP on the A records delete the old deployment. Notes Good thread

101 asp.net on azure: Advanced Techniques

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 resolve tenant by examining host header
Multi-Tenancy SaaS Applications often need to serve multiple tenants out of a single service deployment LB tenant1.saasservice.com tenant2.saasservice.com Slide Objective Explains using host headers to route to an appropriate partition Speaking Notes Scenario in many multi-tenanted SaaS type applications want to run a separate DB per tenant A neat approach is to map a wildcard DNS entry to your primary site Then have a specific subdomain for each customer Tenant1.saasservice.com Tenant2.saasservice.com Needn’t just be subdomains- could lookup on any host name. Use a mechanism to lookup the correct tenant DB based on the incoming host header Send a unique UI down based on the tenant Etc…. Notes Web Roles Shared by all Tenants resolve tenant by examining host header SQL Azure 1 DB per Tenant

104 Web Deploy IIS Web Deployment Tool Simplifies the migration, management, and deployment of IIS Web servers, Web applications, and Web sites You’ll 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

105 ASP.NET ON AZURE: Common Challenges

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) Slide Objective Introduces the challenge of using Windows Azure for file uplaod Speaking Notes Windows Azure instances have a very limited amount of free space In most cases this can be remedied with either Drives of Local resources Both drives and local resources only expose their drive letter/path at run time Problems Uploading file to single instance – could be lost Not good for big files, utilize resources of your website/server Default ASP. NET file upload mechanism requires path to be changed in config This causes issues when uploading large files >~100MB or where many users are uploading files Notes

107 File Upload Solutions Upload direct to Blob storage using Silverlight
Provide a Shared Access Signature to Silverlight control Upload blocks direct to storage [http://tinyurl.com/sl-blob] Use 3rd Party Control Implement a custom IHttpHandler to receive file and buffer to disk Slide Objective Provides approaches for resolving the file upload issue Speaking Notes Upload directly to blob storage Provide a Shared Access Signature (generate in web role) to the client (Silverlight is a good option for an ASP.NET app) Client performs blockwise upload to blob storage Notify web role once upload complete (note cannot call Queue/Table storage directly from client in a secured fashion- i.e. would have to send down the storage key to the client) Use 3rd Party Control Use a 3rd party upload control with a mechanism to modify the drive location where files are streamed to Implement a custom IHttpHandler to receive the uploaded file and buffer to a Local Resource location Notes

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 un’applicazione Web con ASP.NET MVC + Azure
Demo Creazione di un’applicazione Web con ASP.NET MVC + Azure

110 Creazione di un’applicazione Web con ASP.NET MVC
Demo Creazione di un’applicazione Web con ASP.NET MVC

111

112 Questions

113 Imagine cup 2012

114 IMAGINE A WORLD... The most important student technology competition!Let’s 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 structure of the game is entirely up to you!
The Software Design Competition is all about creating real-world applications that can help make the world a better place. The structure of the game is entirely up to you! The goal :Creatively using technology. The IT Challenge is an individual challenge for students around the world who have the nterest, and technical knowledge to design infrastructures. The Game Design: Phone competition is an excellent opportunity to learn the art of mobile video game design!

116 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 guys More at Imagine cup.com/Student stories

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

118 STAY TUNED ON Site: www. MICROSOFT. IT/STUDENTI WWW. IMAGINECUP
STAY TUNED ON Site: Social: FB fanpage Iniziative studenti Mail to:

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

120


Download ppt "Cloud e Web con Windows AZURE e ASP.NET MVC 3"

Similar presentations


Ads by Google