building asp.net apps in windows azure
Post on 24-Feb-2016
95 Views
Preview:
DESCRIPTION
TRANSCRIPT
Building ASP.NET Apps in Windows AzureNameTitleMicrosoft Corporation
Agenda
ASP.NET In Windows Azure Web Forms & MVCAJAX & Stateless Web RolesSession StateDNS
Advanced TechniquesFull IISMulti-tenancyWeb Deploy
ChallengesFile Upload
ASP.NET in Windows Azure
Web Forms and MVCWindows Azure Tools for Visual Studio pre-defined role templatesASP.NET WebForms RoleASP.NET MVC 3 Role
What’s Different?
StatelessnessLoad balancer round-robins requests in multi instance rolesFollow web farm best practicesDo not store state on individual instances Do not assume subsequent requests will hit the same instanceDon’t forget things like dynamically generated images loaded by a page
AJAX and Windows AzureClient side calls may not return to the same instance the original page came fromAJAX calls must be statelessDon’t generate a page and leave state on the server to call via AJAX later
All instances require the same MachineKey for ViewState hashingFabric uses same machine key for all instances in a role
Windows Azure Session StateWindows Azure Load Balancer uses round-robin allocation. Session state must persist to client or storage on every request
LB
session[“foo”] = 1; session[“foo”] = 2;
What is the value of session[“foo”]?
SQL Azure
Windows Azure Storage
Solving Session StatePersist to Storage via Session State ProviderWindows Azure CachingSQL AzureWindows Azure StorageCustom
Persist to ClientUse cookies
Don’t forget ASP.NET MVC TempData relies on Session State provider by default
Windows Azure CachingUsing Windows Azure Caching as the session storeIn-memory, distributed cacheBased on Windows Server CachingMicrosoft.Web.DistributedCache assembly found in the SDKEnable ASP.NET 4 Session Compression
AppFabric Caching Caching
Caching Session StateSession state stored using Windows Azure Caching and an out-of-the-box session state provider
LB
session[“foo”] = 1; session[“foo”] = 2;
What is the value of session[“foo”]?
SQL Server Session StateUse SQL Azure as backing storeRound trip to database twice per requestRead at request startWrite at request end
Enable ASP.NET 4 Session CompressionScale out across multiple DBsUse session state partitioninghttp://bit.ly/scale-session
SQL Azure is competitive on cost basis
SQL Azure Session StateSession state stored using SQL Server Session State Provider and session state partitioning
LB
session[“foo”] = 1; session[“foo”] = 2;
What is the value of session[“foo”]?
SQL Azure 3 x 1GB Databases
Resolve partition
Windows Azure Storage Providers Sample ASP.NET Providers
(Session, Membership, Role etc…)Sample Codehttp://code.msdn.microsoft.com/windowsazuresamplesUses Blob + Table StorageSeveral storage transactions per requestEnable ASP.NET 4 Session Compression
Sample Provider should be treated as a starting point only.
CookiesSerialize and Encrypt state into cookiePossible to implement as Session State ProviderCookies add significant performance overheadCookies sent with every request to domainUse alternative host header to serve images, etc.http://www.myweb.comhttp://images.myweb.com Use Windows Azure Storage for static content
DNSAll services get a *.cloudapp.net addressmyservicename.cloudapp.netTTL is 10 seconds
Standard approach is to CNAME to *.cloudapp.netRequires two DNS lookupsLimited caching due to low TTL
Use A records to point domain root
to your app.Must not delete your role or your IP address will change.
IP Address for deployment is fixed for lifetime of that slot
If you need to plan to delete a servicee.g. Because you need to change external endpoints
High Performance DNS ApproachCreate service, deploy to staging slotResolve IP for yourapp.cloudapp.netCreate A Record forwww.yourapp.comyourapp.com
1 Lower TTL of A Records… wait a while… 2 Create new
service, get new IP, re-point A Records
3 Delete old service
Advanced Techniques
Full IISYou 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 websitesLoad any IIS module
Makes migrating existing IIS-based applications a lot easier
Multi-TenancySaaS Applications often need to serve multiple tenants out of a single service deployment
LB
tenant1.saasservice.com tenant2.saasservice.com
SQL Azure 1 DB per Tenant
resolve tenant by examining host header
Web RolesShared by all Tenants
Web DeployIIS Web Deployment ToolSimplifies the migration, management, and deployment of IIS Web servers, Web applications, and Web sitesPerform web deploy using standard IIS7 publishing from Visual StudioWill not require you to deploy an entire packageWarning: use for development purposes only
Common Challenges
File UploadASP.NET File Upload Control uses ASP.NET temporary directory to buffer filesTemp path cannot be changed to Local Resource or Windows Azure Drive
Windows Azure Compute roles have 100MB of root disk space Problems ariseUploading large files (~100MB)Multiple users uploading concurrently10 users uploading 10MB files
File Upload SolutionsUpload direct to Blob storage using SilverlightProvide a Shared Access Signature to Silverlight controlUpload blocks direct to storage http://bit.ly/sl-blob
Use 3rd Party ControlImplement a custom IHttpHandler to receive file and buffer to disk
Takeaways
ASP.NET In Windows Azure
Advanced Techniques
Challenges
Broad support for ASP.NET FeaturesMust understand and architect for scale out
SaaS Applications usingVirtual Path Providers and Host header checking
© 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.
top related