0
Advanced Cloud ServicesDevelopment (PaaS) Vitor Ciaramella                  Azure Summit Brazil 2013 Technical Evangelist,...
Cloud ServicesUser environment           Internet environment                                                             ...
Automate Cloud              d Service            Stateless s              =   Virtual                    Machineshttp://vi...
Average usage of Cloud ServicesNew applications   Existing web applicationshttp://vic.ms
Advanced Scenarios  Windows Services, Console or GUI applications   including Tomcat, JBoss, Lucene, Solr, Apache, Hadoop,...
Challenges  Installation, Setup and Configuration  Stateful Memory  Stateful Diskhttp://vic.ms
Installation, Setupand Configurationhttp://vic.ms
Install, Setup, Config: possiblesolutions  Use the VM Role   Create a local VHD with Windows Server   Install, setup and c...
Automate the installation  It depends on the installer technology.  Some applications can be installed simply by copying t...
Automate the setup / configuration  It depends on the application.  Some applications can configured simply by overwriting...
Automate the setup / configuration Most Windows Server and IIS configurations can be also changed by using: Powershell    ...
Running the automated script/code  Startup Tasks     Simple: Synchronous execution, one-by-one     Foreground: Asynchronou...
Running the automated script/code  Role, RoleEntryPoint     OnStart: Role stays busy until completion (doesn’t receive req...
Stateful Memoryhttp://vic.ms
Stateful Memory: possible solutions  Rewrite/change your code to not reuse state from subsequent requests  Rewrite/change ...
Stateful Memory with Azure Caching  Add the references to the Azure Caching assemblies.  Edit your web.config or app.confi...
Stateful Memory with Azure Caching  To automatically save the ASP.NET session on the Azure Caching, edit your  web.config ...
Stateful Memory with Azure Caching  Access the Azure Caching programmatically, if you need:  var   cacheFactory = new Data...
Stateful Diskhttp://vic.ms
Stateful Disk: possible solutions  Rewrite/change your code to save the state in a persistent storage   Use Blob or Table ...
Stateful Disk with Azure Drive  Create a VHD and store it in the Blob Storage.  Mount the VHD as local drive in each insta...
Stateful Disk with Azure Drive  Sample Solr/Lucene scenario       Cloud Service           Cloud Service         Cloud Serv...
Stateful Disk with Azure Drive  How to mount a read-only (snapshotted) drive:    var localResource = RoleEnvironment.GetLo...
Stateful Disk with Azure Drive  Delete the snapshot after using it (Role.OnStop)  Use additional logic to “clean-up” unuse...
AutomatedConfiguration andMonitoringhttp://vic.ms
Automated Configuration  Role.OnStart    RoleEnvironment.Changing += RoleEnvironment_Changing;  Role    void RoleEnvironme...
Automated Monitoring  Role.OnStart    RoleEnvironment.StatusCheck += RoleEnvironment_StatusCheck;  Role    void RoleEnviro...
Other Tipshttp://vic.ms
Reduce the size of the Package  Put static files (images, videos, JavaScript, CSS) in the Blob Storage. Adjust  the URLs t...
Prefer Async Processing  Use the Queue Storage or Service Bus (Queues, Topics and Notification  Hub) to distribute work an...
Proactive Caching  All instances read from the cache  One instance is responsible to update the cache periodicallyhttp://v...
Distribute Users and Content  Use CDN to distribute and cache the content (Blobs / Web Roles)  Use the Traffic Manager to ...
Advanced Cloud ServicesDevelopment (PaaS) Vitor Ciaramella                  Azure Summit Brazil 2013 Technical Evangelist,...
Upcoming SlideShare
Loading in...5
×

Advanced cloud services development (PaaS)

322

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
322
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Advanced cloud services development (PaaS)"

  1. 1. Advanced Cloud ServicesDevelopment (PaaS) Vitor Ciaramella Azure Summit Brazil 2013 Technical Evangelist, Microsoft http://vic.mshttp://vic.ms
  2. 2. Cloud ServicesUser environment Internet environment CNAMEUsers Apps / DNS www.myapp.net Browsers Server myapp.cloudapp.net 50.63.202.28 www.myapp.comDev. environment Windows Azure environment Load endpoints BalanceDeveloper r MyAp Cloud Service myapp MyAp MyAp MyAp p p .csconfi p p .csdef MyAp .csde .csconfi Production myapp g .csconfi g .csconfi g p f g Dis Dis Dis Deploy k k k .csconfi Staging MyAp 3f2504e0-4f89-11d3-9a0c-0305e82c3301 p g .csconfi g Dis Dis k Endpoints k definitions VM Image HW Specshttp://vic.ms
  3. 3. Automate Cloud d Service Stateless s = Virtual Machineshttp://vic.ms
  4. 4. Average usage of Cloud ServicesNew applications Existing web applicationshttp://vic.ms
  5. 5. Advanced Scenarios Windows Services, Console or GUI applications including Tomcat, JBoss, Lucene, Solr, Apache, Hadoop, and etc. Specific Windows Server / IIS configuration including hosts file, Registry, IIS Media Services, multiple SSL Certificates, custom IIS AppPool, and etc.http://vic.ms
  6. 6. Challenges Installation, Setup and Configuration Stateful Memory Stateful Diskhttp://vic.ms
  7. 7. Installation, Setupand Configurationhttp://vic.ms
  8. 8. Install, Setup, Config: possiblesolutions Use the VM Role Create a local VHD with Windows Server Install, setup and configure your application and server Upload the VHD as a VM Role disk image Automate the installation, the setup and configuration Create an script/code to automate the installation, the setup and configuration Run it with Startup Tasks Role.OnStart Role.Runhttp://vic.ms
  9. 9. Automate the installation It depends on the installer technology. Some applications can be installed simply by copying their files… For Windows Installer: msiexec.exe /qn /i SQLSysClrTypes.msi /l*v log.txthttp://vic.ms
  10. 10. Automate the setup / configuration It depends on the application. Some applications can configured simply by overwriting their config files… For the Windows Registry: regedit MyRegistryEntriesToBeImported.reg For IIS: %windir%system32inetsrvappcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00http://vic.ms
  11. 11. Automate the setup / configuration Most Windows Server and IIS configurations can be also changed by using: Powershell PS IIS:SitesDemoSiteDemoApp> set-webconfiguration "/system.webServer/handlers/add[@path=*.aspx]/@path“ -value "*.mspx“ .NET Managed APIs: using (var serverManager = new ServerManager()) { var bindingInfo = "*:443:ssl2.myapp.com"; var certStore = (new X509Store(StoreName.My, StoreLocation.LocalMachine)).Name; var site = serverManager.Sites["MySite"]; if (site != null) { var binding = site.Bindings.Add(bindingInfo, certHash, certStore); binding.SetAttributeValue("sslFlags", 1); serverManager.CommitChanges(); } }http://vic.ms
  12. 12. Running the automated script/code Startup Tasks Simple: Synchronous execution, one-by-one Foreground: Asynchronous execution, keeps the role running Background: Asynchronous execution, does not keep the role running <Startup> <Task taskType="simple" commandLine="startupstartup.cmd" executionContext="elevated"> <Environment> <Variable name="azurestoragename" value="mystorage" /> </Environment> </Task> </Startup>http://vic.ms
  13. 13. Running the automated script/code Role, RoleEntryPoint OnStart: Role stays busy until completion (doesn’t receive requests), up to 15 minutes Run: Role recycles when exit this method (so, keep it running). Ready to receive requests. OnStop: Before role stops (clean up), up to 30 seconds Execution Context: <Runtime executionContext="elevated“ />http://vic.ms
  14. 14. Stateful Memoryhttp://vic.ms
  15. 15. Stateful Memory: possible solutions Rewrite/change your code to not reuse state from subsequent requests Rewrite/change your code to save the state in a persistent or semi-persistent storage Use Blob or Table Storage Use SQL Database Use Windows Azure Caching (recommended)http://vic.ms
  16. 16. Stateful Memory with Azure Caching Add the references to the Azure Caching assemblies. Edit your web.config or app.config file with: <dataCacheClients> <dataCacheClient name="default" maxConnectionsToServer="1"> <hosts> <host name=“myapp.cache.windows.net" cachePort="22233" /> </hosts> <securityProperties mode="Message"> <messageSecurity authorizationInfo="YWNzOmh0dHBzOi8vdG…"> </messageSecurity> </securityProperties> </dataCacheClient> </dataCacheClients>http://vic.ms
  17. 17. Stateful Memory with Azure Caching To automatically save the ASP.NET session on the Azure Caching, edit your web.config with: <configuration> <system.web> <sessionState mode="Custom" customProvider="DistributedSessionProvider" compressionEnabled="false"> <providers> <add name="DistributedSessionProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider,Microsoft .Web.DistributedCache" cacheName="default" applicationName=“MyApp" useBlobMode="false"/> </providers> </sessionState> </system.web> </configuration>http://vic.ms
  18. 18. Stateful Memory with Azure Caching Access the Azure Caching programmatically, if you need: var cacheFactory = new DataCacheFactory(); var myCache = cacheFactory.GetDefaultCache(); var key = "DataAtual"; var cachedObject = myCache.Get(key); if (cachedObject != null) { var value = (DateTime) cachedObject; } else { var value = DateTime.Now.Date; myCache.Put(key, value, TimeSpan.FromSeconds(15)); }http://vic.ms
  19. 19. Stateful Diskhttp://vic.ms
  20. 20. Stateful Disk: possible solutions Rewrite/change your code to save the state in a persistent storage Use Blob or Table Storage (recommended) Use SQL Database Use Azure Drivehttp://vic.ms
  21. 21. Stateful Disk with Azure Drive Create a VHD and store it in the Blob Storage. Mount the VHD as local drive in each instance. Attention: Only one instance can mount it with Read/Write access. MyApp MyApp MyApp MyApp .csconfig .csconfig .csconfig .csconfig Disk Disk Disk Disk Disk Disk Disk Disk Blob Storage Disk.vhdhttp://vic.ms
  22. 22. Stateful Disk with Azure Drive Sample Solr/Lucene scenario Cloud Service Cloud Service Cloud Service Instance Instance Instance Query Query Query Read only Read only Read only VM Disk Disk Disk Index Read write R/W Mount Blob Storage Disk.vhd Diskhttp://vic.ms
  23. 23. Stateful Disk with Azure Drive How to mount a read-only (snapshotted) drive: var localResource = RoleEnvironment.GetLocalResource("LocalDriveCache"); CloudDrive.InitializeCache(localResource.RootPath, localResource.MaximumSizeInMegabytes); var storageAccount = CloudStorageAccount.FromConfigurationSetting(“LuceneVHDs"); var client = storageAccount.CreateCloudBlobClient(); var container = new CloudBlobContainer("vhds", client); var pageBlob = container.GetPageBlobReference(“lucene.vhd"); var drive = new CloudDrive(pageBlob.Uri, storageAccount.Credentials); drive = new CloudDrive(drive.Snapshot(), storageAccount.Credentials); var driveLetter = drive.Mount(localResource.MaximumSizeInMegabytes, DriveMountOptions.None); //e.g.: driveLetter = “H:”http://vic.ms
  24. 24. Stateful Disk with Azure Drive Delete the snapshot after using it (Role.OnStop) Use additional logic to “clean-up” unused/old snapshots. How to list snapshots of a blob: var pageBlob = container.GetPageBlobReference(“lucene.vhd"); var snapshots = container.ListBlobs(new BlobRequestOptions() { BlobListingDetails = BlobListingDetails.Snapshots, UseFlatBlobListing = true, }).OfType<CloudPageBlob>().Where((blob) => blob.SnapshotTime.HasValue && blob.Uri.Equals(pageBlob.Uri)).OrderByDescending((blob)=>blob.SnapshotTime).ToList();http://vic.ms
  25. 25. AutomatedConfiguration andMonitoringhttp://vic.ms
  26. 26. Automated Configuration Role.OnStart RoleEnvironment.Changing += RoleEnvironment_Changing; Role void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e) { MyApplyChanges(e.Changes); e.Cancel = MyCheckIfNeedsToReboot(); }http://vic.ms
  27. 27. Automated Monitoring Role.OnStart RoleEnvironment.StatusCheck += RoleEnvironment_StatusCheck; Role void RoleEnvironment_StatusCheck(object sender, RoleInstanceStatusCheckEventArgs e) { var isHealthy = CheckMyHealth(); if (!isHealthy) e.SetBusy(); }http://vic.ms
  28. 28. Other Tipshttp://vic.ms
  29. 29. Reduce the size of the Package Put static files (images, videos, JavaScript, CSS) in the Blob Storage. Adjust the URLs to these resources. Put installers and large executables in the Blob Storage. Download these files locally using Startup Tasks / Role.OnStarthttp://vic.ms
  30. 30. Prefer Async Processing Use the Queue Storage or Service Bus (Queues, Topics and Notification Hub) to distribute work and scale processing Use the .NET framework 4.5 parallel and async featureshttp://vic.ms
  31. 31. Proactive Caching All instances read from the cache One instance is responsible to update the cache periodicallyhttp://vic.ms
  32. 32. Distribute Users and Content Use CDN to distribute and cache the content (Blobs / Web Roles) Use the Traffic Manager to direct users to the closest datacenterhttp://vic.ms
  33. 33. Advanced Cloud ServicesDevelopment (PaaS) Vitor Ciaramella Azure Summit Brazil 2013 Technical Evangelist, Microsoft http://vic.mshttp://vic.ms
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×