Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SQL Azure and Data-tier Applications (DACPAC)

3,808 views

Published on

An overview of how Data-tier Applications (DACPACs) work with SQL Azure and SQL Server 2008. Also included is how this Microsoft technology fits in with a continuous integration (CI) process. Visit my blog for more details: http://andrewmatthewthompson.blogspot.com/

Published in: Technology
  • Be the first to comment

  • Be the first to like this

SQL Azure and Data-tier Applications (DACPAC)

  1. 1. SQL AZURE AND DATA-TIER APPLICATIONS Vancouver Windows Azure Meetup Group
  2. 2. ANDREW THOMPSON Senior Software Engineer @
  3. 3. Some Background First...
  4. 4. WE WERE BUILDING THIS Presentation tier Middle tier Data tier
  5. 5. BUT WE THOUGHT ABOUT THIS Presentation tier Middle Middle Middle Middle tier tier tier tier Data tier Data tier Data tier
  6. 6. SO WE MOVED TO THE CLOUD Presentation tier Middle tier } Web Roles Data tier } SQL Azure
  7. 7. 3 Months
  8. 8. The Problem...
  9. 9. EVERYTHING WAS ALWAYS BROKEN Alter Table Alter Procedure SQL ServerCreate Procedure Drop Table
  10. 10. A single development database doesnt work for long.
  11. 11. Difficulty # Developers
  12. 12. How can we scale database modifications?
  13. 13. POSSIBILITIES
  14. 14. POSSIBILITIES• Hand rolled SQL scripts
  15. 15. POSSIBILITIES• Hand rolled SQL scripts• Liquibase
  16. 16. POSSIBILITIES• Hand rolled SQL scripts• Liquibase• Redgates SQL tools
  17. 17. POSSIBILITIES• Hand rolled SQL scripts• Liquibase• Redgates SQL tools• Visual Studio’s database tools
  18. 18. What database project do we use?
  19. 19. Uh oh... we’re using the database project
  20. 20. What is a Data-tier Application?
  21. 21. TERMINOLOGYhttp://dacguy.wordpress.com/2011/09/09/dac-concepts
  22. 22. TERMINOLOGY• DAC http://dacguy.wordpress.com/2011/09/09/dac-concepts
  23. 23. TERMINOLOGY• DAC• DACFx http://dacguy.wordpress.com/2011/09/09/dac-concepts
  24. 24. TERMINOLOGY• DAC• DACFx• DAC Package (DACPAC) http://dacguy.wordpress.com/2011/09/09/dac-concepts
  25. 25. TERMINOLOGY• DAC• DACFx• DAC Package (DACPAC)• BACPAC http://dacguy.wordpress.com/2011/09/09/dac-concepts
  26. 26. DACPAC
  27. 27. HOW DO YOU INTERACT WITH IT?
  28. 28. HOW DO YOU INTERACT WITH IT?• Right-click menus (SSMS or VS2010)
  29. 29. HOW DO YOU INTERACT WITH IT?• Right-click menus (SSMS or VS2010)• .NET
  30. 30. HOW DO YOU INTERACT WITH IT?• Right-click menus (SSMS or VS2010)• .NET• PowerShell
  31. 31. GETTING STARTEDExtract a data-tier application from your existing database
  32. 32. USE CASEUpgrade data-tier application locally
  33. 33. USE CASEUpgrade data-tier application on CI
  34. 34. }[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Sdk.Sfc")[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.Dac")[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") Dependencies$sqlConnection = new-object System.Data.SqlClient.SqlConnection($connectionString) }$serverConnection = new-object Microsoft.SqlServer.Management.Common.ServerConnection( $sqlConnection)$serverConnection.Connect();$sqlStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection( Connections $serverConnection.SqlConnectionObject)$connectSuccessful = $sqlStoreConnection.Connect()$dacStore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($serverConnection)$upgradeOptions = New-Object Microsoft.SqlServer.Management.Dac.DacUpgradeOptions$upgradeOptions.BlockOnChanges = $false$upgradeOptions.IgnoreDataLoss = $true$upgradeOptions.RollbackonFailure = $true$upgradeOptions.SkipPolicyValidation = $false } Options$dacChanges = $dacStore.GetDatabaseChanges($dataTierAppNameToUpgrade) | Out-File -Filepath .DatabaseChanges.txt$dacStore.GetIncrementalUpgradeScript($dataTierAppNameToUpgrade, $nextDacType) | Out-File -Filepath .DatabaseUpgrade.sql } Review$dacStore.IncrementalUpgrade($dataTierAppNameToUpgrade, $nextDacType, $upgradeOptions) } Upgrade
  35. 35. USE CASEUpgrade data-tier application on Production
  36. 36. Continuous Integration (CI)
  37. 37. TIP Use the DACPAC version # toavoid pushing unnecessary changes
  38. 38. TIPWatch out for previous DACFx versions
  39. 39. Pros & Cons...
  40. 40. CONS
  41. 41. CONS• All schema modifications should occur within Visual Studio
  42. 42. CONS• All schema modifications should occur within Visual Studio• Online documentation is a bit scarce
  43. 43. CONS• All schema modifications should occur within Visual Studio• Online documentation is a bit scarce• Deployments to SQL Azure can take a while (5 - 30 mins)
  44. 44. CONS
  45. 45. CONS• Many questions around how this works with Azure Data Sync
  46. 46. CONS• Many questions around how this works with Azure Data Sync• It won’t do everything for you
  47. 47. PROS
  48. 48. PROS• Developers can seamlessly sync database changes
  49. 49. PROS• Developers can seamlessly sync database changes• Dev-ops or DBAs can feel comfortable with DACPACs
  50. 50. PROS• Developers can seamlessly sync database changes• Dev-ops or DBAs can feel comfortable with DACPACs• Code analysis
  51. 51. PROS
  52. 52. PROS• Options to stop deployments under certain conditions
  53. 53. PROS• Options to stop deployments under certain conditions• Schema/SQL change tracking
  54. 54. PROS• Options to stop deployments under certain conditions• Schema/SQL change tracking• You define the schema and it figures out how to apply it
  55. 55. What will the future hold?
  56. 56. Questions?andrew.thompson@resaas.com

×