Windows Azure and Silverlight: A Match Made For the Web Matthew Kerner Program Manager Windows Azure Fabric Controller [email protected].

Download Report

Transcript Windows Azure and Silverlight: A Match Made For the Web Matthew Kerner Program Manager Windows Azure Fabric Controller [email protected].

Windows Azure and Silverlight:
A Match Made For the Web
Matthew Kerner
Program Manager
Windows Azure Fabric Controller
[email protected]
1
Silverlight & Azure
• Silverlight: rich & functional UI
• Azure: deployment/upgrade, monitoring,
throughput, scalability, geo-replication
• What if we connect the dots?
– A little bit of Azure will go a long way for Silverlight
developers
• Today’s talk
– A Little Bit of Azure
– Silverlight & Azure Design Patterns
– Tips and Tricks
2
Demo:
http://powerzoom.blob.core.windows.net/supersecretslides/SuperSecret
Slides.html
A LITTLE BIT OF AZURE
3
So What?
• Stop worrying about racking & stacking, OS &
service deployment & servicing, monitoring
• No up-front capex, just pay as you grow
• Geo-distribution & massive scale
– Energy efficiency and cost savings
• Developers can focus on business and
customers, not operations & administration
4
Windows Azure Components
Windows Azure SDK
Dev Fabric Dev Storage
Application Package
5
Diversion: Service Model
Service Model
Roles & Interfaces
LB
Policies
Update 20% of the
service at any one
time
Front End
Front End
Front
End
Front
End
Biz Logic
Configuration Settings
ConnectionString=fabrikam.com:80
MaxTimeout=20
…
6
Windows Azure Components
Windows Azure SDK
Dev Fabric Dev Storage
Application Package
Service Management API
Browser
Silverlight
Production Fabric &
Storage
CDN
Geo-Distributed
Datacenters
7
Silverlight hosted on Windows Azure
Silverlight accessing Windows Azure Storage
Storage-Only
DESIGN PATTERNS
8
Pattern: Silverlight Hosted on
Azure
Browser
Silverlight
Hosted App
ASP.NET
XAP
• Pattern
– ASP.NET website hosted in Windows Azure
– XAP file hosted on the website, used in the browser
– Like an on-premises website, but has the flexibility of the cloud (geo,
scale, easy deployment & upgrade)
• Demo
– Converting an existing Silverlight project to a cloud project
– Running in the dev fabric
– Deploying to the cloud
9
Windows Azure Storage
• Windows Azure Storage
–
–
–
–
Durable, highly available, highly scalable
Tables, Blobs, and Queues
REST API & .Net Storage Client Library
Pay per GB stored, transferred, and per transaction
• Proxy via a {ASP.NET, WCF} hosted compute service
Browser
Silverlight
Hosted App
ASP.NET
XAP
Table
Storage
• You might think to access tables directly from the browser with REST, but…
– Key leakage
– No authentication headers or storage client library in Silverlight
– Cross-domain issues
10
Blob Storage Access
• Offload blob access directly to blob storage
– Avoid load & latency for images, video, music
• Public anonymous access with global CDN
Browser
Silverlight
Hosted App
ASP.NET
XAP
Blob
Storage
Media
XAP
• Can serve XAP from blob storage too
• For some scenarios, add cross-domain policy file
to the root blob container
11
Authenticated Blob Storage
Access
• Scenarios
– Paid content
– Prevent deep linking (e.g. context, ad revenue)
• Shared access signatures (aka pre-authorized
URLs)
– Grant specific rights for a specific time window
– Extend & revoke on demand
12
Pattern: Shared Access
Signatures
2. Return the URL to the client
Browser
Silverlight
Hosted App
ASP.NET
Key
3. Client accesses blob storage directly
Blob
Storage
Media
XAP
1. Generate Shared Access Signature
• Account key is stored securely in the cloud
• Proxy service generates shared access
signatures on client demand using that key
• Browser accesses blob storage directly to
avoid latency & load on hosted app
13
Sample: Shared Access
Signatures
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
var csa =
CloudStorageAccount.FromConfigurationSetting("StorageAccount");
var cbc = csa.CreateCloudBlobClient();
var blobRef = cbc.GetBlobReference(@"paidcontent\mysong.wma");
var sap = new SharedAccessPolicy()
{
SharedAccessExpiryTime = DateTime.UtcNow+TimeSpan.FromMinutes(30.0),
Permissions = SharedAccessPermissions.Read
};
var sas = blobRef.GetSharedAccessSignature(sap);
// Keep SAS private w/SSL (distribution & in the URL itself)
Response.Redirect(blobRef.Attributes.Uri + sas);
14
Compute-to-Browser
Browser
Silverlight
Hosted App
ASP.NET
HTML
Blob
Storage
Media
XAP
•
•
•
•
Static sites may not need hosted compute
Push all compute to the browser
Serve XAP & media from public root container
Use the CDN to serve blobs from the edge
15
Cloud Tips
Visual Studio & Azure
Silverlight
WCF
TIPS, TRICKS & GOTCHAS
16
Cloud Tips
•
•
•
•
Crawl: dev fabric & dev storage
Walk: dev fabric & prod storage
Run: prod fabric & prod storage
Windows Azure Diagnostics gives you visibility
into the cloud from your desktop
• Various storage clients available
(myazurestorage.com, Cerebrata, Clumsy Leaf,
etc.)
• csmanage sample allows you to script
deployment, config changes, etc
17
Visual Studio & Azure
• Use .Net Framework 3.5 in the cloud (for now)
– Remove broken reference to Microsoft.CSharp
• Recommend built-in MVC web role
– Sets Copy Local = True for System.Web.MVC
• Use web app (not web site) for cloud projects
• Adding existing roles to a cloud project
– Remember to add them to the role list
• Adding a cloud project to an existing project
– Remember to set the cloud project as the startup
project
18
Silverlight
• Either Silverlight or JS debugging, but not both
• Add Silverlight MIME type to support Silverlight in
dev fabric
– Open IIS Configuration Manager
– Double click MIME Types on the right hand side
– Map from .xap to application/x-silverlight-app
• Remember to allow public access to the root blob
container
– Add a cross-domain policy file as necessary
• Smooth streaming not yet supported in Azure but
progressive HTTP works
19
WCF
• WCF considerations for load-balanced endpoints
– Load-balanced endpoint flags
– Consider connection timeouts (1 minute)
• Asynchronous patterns work well
– PollingDuplexHttpBinding expects affinity
• Store client state centrally across frontend role instances
• Different port mappings in the cloud
– Quick: Patch port mappings in auto-generated service
reference
– Fancy: Generate your own metadata
• http://code.msdn.microsoft.com/wcfazure/Wiki/View.
aspx?title=KnownIssues
20
Other Azure Services
• SQL Azure
– SQL database in the cloud
– Provisioned on-demand with high availability
– No physical administration required
• Windows Azure Platform AppFabric
– Service bus
• Connect securely between on-premise services and cloud services
– Firewall traversal with message rendezvous in the cloud
– Access Control
• Single sign-on to your service for your customers using their
existing identity system
– Federated identity, claims-based authentication
21
Summary
• Azure makes running services easy
– Automated deployment & management
– Scale
– Geo-distribution
• Azure & Silverlight are a great match
• Getting Started
– Install the Azure Tools for VS
– Run a Silverlight app in the Dev Fabric
– Run a Silverlight app in the cloud
22
Further Information
• Getting Started: http://dev.windowsazure.com/
–
–
–
–
–
VS Tools: http://go.microsoft.com/fwlink/?LinkID=128752
Dev Portal: http://windows.azure.com/
Forum: http://social.msdn.microsoft.com/forums/en-us/windowsazure
Docs: http://msdn.microsoft.com/en-us/library/dd179442.aspx
Blog: http://blogs.msdn.com/windowsazure/
• Tips
– Jim Nakashima’s blog (lots of tips): http://blogs.msdn.com/jnak/
– WCF on Azure Sample: http://code.msdn.microsoft.com/wcfazure
– WCF on Azure Tips:
http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues
– Additional samples: http://code.msdn.microsoft.com/windowsazuresamples
• Useful PDC 2009 talks:
– My First Azure App: http://microsoftpdc.com/Sessions/SVC37
– Diagnostics on Azure: http://microsoftpdc.com/Sessions/SVC15
– Service Management: http://microsoftpdc.com/Sessions/SVC25
23