c fowler azure-dojo
DESCRIPTION
Migrating an Application to Windows AzureTRANSCRIPT
![Page 1: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/1.jpg)
Migrating an Application to
Windows Azure
Cloud Dojo
![Page 2: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/2.jpg)
Cory Fowler Consultant, ObjectSharp Microsoft MVP, Windows Azure @SyntaxC4 http://blog.syntaxc4.net gettag.mobi
I’m all in.
![Page 3: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/3.jpg)
Starter Site: Nerd Dinner
ASP.NET MVC
SQL Server
Entity Framework
IIS
![Page 4: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/4.jpg)
Resulting Site: Nerd Dinner
ASP.NET MVC
SQL Azure
Entity Framework
Windows Azure
Windows Identity Foundation
![Page 5: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/5.jpg)
A Quick word on Tools
![Page 6: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/6.jpg)
Alright, Let’s do this…
![Page 7: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/7.jpg)
Windows Azure!!!
![Page 8: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/8.jpg)
Windows Azure Compute
JIT Knowledge
![Page 9: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/9.jpg)
A Hosted Service is a container for an Application.
An Application must consist of at least one Role.
A Role is Scalable to meet the demand of traffic.
![Page 10: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/10.jpg)
Ro
le
Web Ro
le
Worker Ro
le
VM ASP.NET
WCF
Fast CGI
Emulates IIS
Long Running Process
Emulates Windows Services
Windows Server 2008 R2
Customized Guest OS
![Page 11: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/11.jpg)
Web Site
Web Site Web Site
Web Site Back-End Services
Admin Site
Application Roles
[Web Role] [Worker Role] [VM Role]
![Page 12: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/12.jpg)
Convert your Web Application
To a Web Role
![Page 13: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/13.jpg)
Add Cloud Project
1. Right-Click on Solution File.
2. Hover over Add Menu Item.
3. Click New Project.
4. Select your Language of Choice.
5. Select Cloud.
6. Name your Project and hit OK.
![Page 14: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/14.jpg)
Azurify your Web Application
1. Right-Click on Web Project
2. Click Manage NuGet Packages
3. Filter using Azure Web Role
4. Install Windows Azure Web Role
Or
1. Open Package Manager Console
2. Type
Install-Package WindowsAzure.WebRole
-ProjectName NerdDinner PM>
![Page 15: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/15.jpg)
Associate your Web & Cloud Projects
1. Right-Click on Roles Folder in Cloud Project. 2. Click Web Role Project in Solution. 3. Select the Nerd Dinner Project from the
Dialog. 4. Click OK.
![Page 16: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/16.jpg)
What did I just do…?
JIT Knowledge
![Page 17: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/17.jpg)
Cloud Configuration
ServiceDefinition.csdef [Life-Time]
ServiceConfiguration.cscfg [Modifiable]
![Page 18: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/18.jpg)
<?xml version="1.0" encoding="utf-8"?> <ServiceDefinition name="ExploringServiceDefinition" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> <WebRole name="" vmsize="ExtraSmall" enableNativeCodeExecution="true"> <!-- ... --> </WebRole> <WorkerRole name="" vmsize="ExtraSmall"> <!-- ... --> </WorkerRole> <VirtualMachineRole name="" vmsize="ExtraSmall"> <!-- ... --> </VirtualMachineRole> </ServiceDefinition>
Service Definition
![Page 19: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/19.jpg)
Service Configuration
<ServiceConfiguration serviceName="NerdDinner.Cloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*"> <Role name="MvcWebRole1"> <Instances count="1" /> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> </ConfigurationSettings> </Role> </ServiceConfiguration>
![Page 20: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/20.jpg)
WebRole.cs public class WebRole : RoleEntryPoint
{
// Included in Both Web and Worker Role Template
public override bool OnStart()
{
RoleEnvironment.Changing += RoleEnvironmentChanging;
return base.OnStart();
}
// Included in Worker Role Template - Still available in Web Role but needs to be overridden
public override void Run() { base.Run(); }
// Not Included but available in Web and Worker Roles
public override void OnStop() { base.OnStop(); }
// Is not generated ANYWHERE but SHOULD be Implemented
private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{
// If a configuration setting is changing
if (e.Changes.Any(change =>
change is RoleEnvironmentConfigurationSettingChange))
e.Cancel = true; // Set e.Cancel to true to restart this role instance
}
}
![Page 21: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/21.jpg)
Prepare your Database
For SQL Azure
![Page 22: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/22.jpg)
SQL Azure
Feature Set
Web Edition Business Edition
1GB, 5GB 10-50GB
Data Types XML, Sparse Columns, Filestream
Partitions Full-text indexes SQL-CLR
Tables, indexes and views
Stored Procedures
Triggers
Constraints
Table variables, session temp tables (#t)
Spatial types, HierarchyId
![Page 23: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/23.jpg)
Attach NerdDinner Database
1. Open SQL Server Management Studio (SSMS)
2. Connect to .\SQLExpress
3. Right-Click on Databases
4. Click Attach…
5. Find NerdDinner.mdf in App_Data
6. Click OK
![Page 24: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/24.jpg)
Generate Scripts for SQL Azure
1. Right-Click Attached NerdDinner Database
2. Click Tasks
3. Click Generate Scripts…
4. Change Database Engine Type to
SQL Azure
5. Click OK
6. Click Finish
![Page 25: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/25.jpg)
https://<servername>.database.windows.net [SSMS]
Connect to SQL Azure
![Page 26: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/26.jpg)
Create SQL Azure Database New-SqlAzureServer -SubscriptionId -Certificate -AdministratorLogin -AdministratorLoginPassword -Location
1. Sign in to Windows Azure Portal 2. Open SQL Azure Section 3. Create Server
a) Select Region b) Create Administration Credentials c) Add Firewall Rules
4. Create Database a) Enter Database name b) Click OK
5. Copy Connection String from Properties
Powershell for Firewall Rules: http://bit.ly/qCvdpN
![Page 27: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/27.jpg)
Run the NerdDinner Scripts
1. Open [ File | Script ] NerdDinner.sql
2. Execute Script
![Page 28: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/28.jpg)
Cloud Aware Configuration
Get it on GitHub: http://bit.ly/r7Hvj0
web .config
Cloud Service .cscfg
ConnectionStringResolver .Create() .WithCloudConnectionStringName ("NerdDinnerEntities") .WithLocalConnectionStringName ("NerdDinnerEntities") .ConnectionString
![Page 29: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/29.jpg)
A Quick Note on Data Migration
DTS Wizard (SSIS) http://bit.ly/gzLsl9 BCP Utility http://bit.ly/bQdAIn Import/Export [Blog on Import/Export CTP]
SQL Azure Data Sync
Tools
![Page 30: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/30.jpg)
What About AuthN?
Claims Based Windows Azure Storage SQL Azure
![Page 31: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/31.jpg)
SQL Membership Approach
Remember aspnet_regsql?
Download the Updated SQL Azure supported Scripts
http://bit.ly/gB5DIt
PM> Install-Package System.Web.Providers
![Page 32: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/32.jpg)
Windows Azure Storage
Account Container Item
BLOB Storage
TABLE Storage
QUEUE[S] Storage
http[s]://account.*.core.windows.net
NerdDinner images
videos Blobs
NerdDinner
NerdDinner
locations
dinners Entities
rsvp
resize Messages
![Page 33: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/33.jpg)
Windows Azure Storage Membership Approach
** Experimental **
Download ASP.NET Samples: http://bit.ly/pEguoW
<membership defaultProvider="TableStorageMembershipProvider"> <providers> <clear />
<add name="TableStorageMembershipProvider“ type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider" description="Membership provider using table storage" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="true" passwordFormat="Hashed" allowInsecureRemoteEndpoints="true" />
</providers> </membership>
![Page 34: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/34.jpg)
Claims Based Authentication
Windows Azure Access Control Service
ACS (v2.0) enables AuthN with: Active Directory Federation Service [ADFS] Facebook Google LiveID Yahoo! WS-Fed WS-Trust
![Page 35: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/35.jpg)
How Does Claims Based AuthN Work?
JIT Knowledge
![Page 36: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/36.jpg)
Access Control Services Customer
3. Send claims
Google ID Application
0.2 No Auth
0.3 Redirect to provider
![Page 37: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/37.jpg)
Application 6. Send identity
Claims Framework
Your App
7. Consume identity
4. Normalize identity
Access Control Services
Customer
![Page 38: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/38.jpg)
ACS Friendly AuthN Screen Changing this…
Into this…
![Page 39: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/39.jpg)
Create Access Control Namespace
1. Open the Windows Azure Platform Portal 2. Select Service bus, Access Control & Caching from the lower
left-hand menu 3. Click New 4. Ensure Access Control is selected
5. Provide a Namespace for your AppFabric Endpoint
6. Click Check Availability 7. Select a Region 8. Click Create Namespace 9. Click on Manage Access Control Service
![Page 40: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/40.jpg)
Add an Identity Provider
1. Select Identity Provider (IP) i. Google ii. Yahoo!
2. Click Next 3. Add path to IP Logo 4. Click Save
![Page 41: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/41.jpg)
Create Relying Party Application
1. Enter Name 2. Enter Realm [localhost is allowed] 3. Enter Return URL [localhost is allowed] 4. Select SAML 1.1 5. Select Identity providers
i. Google ii. Windows Live
6. Select Create new rule group 7. Select Use service namespace certificate
![Page 42: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/42.jpg)
Enable Claims-Based AuthN
1. In Visual Studio. Tools > Add STS Reference 2. Ensure the Web.config location is correct 3. Enter the Application Url
Requires Windows Identity Foundation SDK
![Page 43: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/43.jpg)
4. Select Use an existing STS 5. Login to Windows Azure Portal 6. Navigate to ACS Menu 7. Select AppFabric endpoint 8. Click manage ACS Service 9. Click on Application integration 10. Select & Copy WS-Federation Metadata Url 11. Switch back to Federation Utility 12. Paste Endpoint in Textbox 13. Next through the remainder of the Tool.
Enable Claims-Based AuthN
![Page 44: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/44.jpg)
MVC WS-Federation Fix
<httpRuntime requestValidationType= "SyntaxC4.WindowsAzure.ACSManagement.Mvc.WsFederationRequestValidator" />
PM> Install-Package SyntaxC4.WindowsAzure.ACSManagement.Mvc
![Page 45: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/45.jpg)
Include WIF in cspkg
Copy Local = True isn’t enough in this case
Specific Version must be False
![Page 46: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/46.jpg)
Home Realm Discovery Wrapped Up!
public ActionResult LogOn() { var manager = new ACSServiceManager("nerddinnerc4", "http://127.0.0.1:81/"); IIdentityProvider[] providers = manager.GetIdentityProviders<IdentityProvider>(); return View(providers); }
PM> Install-Package SyntaxC4.WindowsAzure.ACSManagement
Home Realm Discovery is the act of retrieving a list of the Identity Providers that are available to your application.
![Page 47: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/47.jpg)
Create a Custom Login Screen
<ul class="login"> <% foreach (var ip in Model) { %> <li class="login-item">
<object data="<%: ip.ImageUrl %>" onclick="javascript:location.href='<%: ip.LoginUrl %>'"> <a href="<%: ip.LoginUrl %>" class="login-item-link"> <%: ip.Name %></a> </object> </li>
<% } %> </ul>
![Page 48: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/48.jpg)
To the Cloud!
![Page 49: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/49.jpg)
Publish to Windows Azure 1. Right-Click on Cloud Project 2. Select Publish… 3. Select <Add…> from Credentials Dropdown list
a) Give Certificate a Friendly Name b) Copy Certificate Path c) Upload Certificate to Management Portal d) Paste SubscriptionId into dialog
4. Select Deployment Environment 5. Select Storage Account 6. Select Cloud Service
Configuration 7. Select Release Build
Configuration 8. Click Publish
![Page 50: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/50.jpg)
Dinner Time!
![Page 51: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/51.jpg)
Next Steps…
Geo-Distributed with
Traffic Manager
Decrease Latency with Windows Azure CDN
Phone App?
![Page 52: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/52.jpg)
Cloudy Reading
![Page 53: C fowler azure-dojo](https://reader034.vdocument.in/reader034/viewer/2022051817/547e97195906b5a6718b469c/html5/thumbnails/53.jpg)
Resources
Blog http://blog.syntaxc4.net
GitHub http://github.com/syntaxc4
Windows Azure Platform Training Kit http://bit.ly/jXfyyD
Windows Azure Powershell Cmdlets http://bit.ly/m75gEc
Windows Azure Tools http://bit.ly/miooC4
Cloud Cover Show http://bit.ly/g4nQbT
Essential Resources for Windows Azure http://bit.ly/efmzGo