Upload
roland-osborne
View
221
Download
0
Tags:
Embed Size (px)
Citation preview
Exploring SQL Server Data Tier Applications
Bob BeaucheminDeveloper Skills PartnerSQLskills
DBI309
Agenda
Data-Tier ApplicationsAnd Multi-Server ManagementAnd SQL Azure DatabaseAnd Visual Studio/SQL Server Data Tools
Working with DACs, DACPACs, and BACPACsCreating/Extracting and Deconstructing DACPACsDeployment
Initial deploymentUpgrade
Import and Export - BACPAC
First, Some Terms
DACEncompasses all other names and concepts
DACFxThe DAC Framework, DLLs
DACPACThe file format used by DACFx that contains the full declarative definition of a database schema. Best analogy: an MSI.
BACPACThe file format used by DACFx to contain the definition of an application/database schema as well as its (table) data.
What Does It Do?
SQL Server Data Tools/DACFx features include:Building a DACPAC from a set of T-SQL scripts Extracting a DACPAC from a databaseDeploying a DACPAC to a new databaseIncrementally upgrading an existing database schema via DACPACExporting a BACPAC from an existing databaseImporting a BACPAC to a new/empty database Schema comparisonOnline Database Development Tools
What's The Point?
Provides services around SQL ServerDatabase extraction and packagingFile formats are SQL Server version-independent
DAC features enableManaged database application lifecycleSchema and data portability
What Problem Does It Solve?
Meant to simplify deployment acrossSQL Server release/version differences
Features, T-SQL dialect
SQL Azure vs. SQL ServerT-SQL dialect, other differences
Others…Migrating database between instances
On Prem => SQL Azure and back or between On Prem
DAC Scenarios
A Quick DAC History
DAC 1.0SQL Server 2008 R2 UtilityVS 2010 SP1 DAC Project
DAC 1.1 – Upgrade in PlaceDAC 2.0 – Object support for SQL Azure, BACPACDAC 3.0
SQL Server 2012/SQL Server Data ToolsObject support for SQL Server 2005-above, SQL Azure
DACFx 3.0 in SSMS 2012
On SQL Server or SQL Azure node in Object ExplorerDatabases Folder
Deploy (from DACPAC)Import (from BACPAC)
Local file system or Windows Azure storage
Individual Databases/TasksExtractMigrate Database to Azure (using BACPAC)Export (to BACPAC)
Local file system or Windows Azure storage
RegisterUpgradeDelete (Unregister)
Consumers
DACFx 3.0 is used bySQL Server Management Studio 2012SQL Server Data Tools (SSDT)SqlPackage.exeDACFx Managed API
DACFx is also used bySQL Azure Management PortalSQL Azure Import/Export ServiceSQL Server Utility (3.0 in SQL Server 2012)
Creating a DACPAC
From an existing databaseSSMS 2008 R2 and above
Choose "Extract Data-Tier Application" from database
Also available from SqlPackage.exe or DACFX APIDAC v3.0 support built-in to SQL Server Data Tools project
In VS 2010 Professional +/VS2012Populate project from existing database or DACPAC filePopulate project from DDL scriptsStart from empty project
.dacpac file is build output of SSDT project
Permitted Objects
DAC 3.0 – Full SQL Server/Azure domain supportedDAC 2.0 – all SQL Azure-compatible objects supportedDAC 1.0/1.1 supports
Tables, Views, and IndexesMultiple schemas supportedIncludes constraints, collations, computed columns
Sprocs, Functions, DML Triggers (in T-SQL)Logins (deployed to Master), Users, RolesUser-defined Table Types
Includes UDDT
Data-Tier Application Elements
Application properties (appname, version, and desc.)Database object definitionsInstance-level object definitions (logins, collations, compatibility level)Server-selection policy (pre-3.0)Pre/post-deployment scripts.dacpac is a OPC package
Contains multiple XML filesDoes not contain any user data
DAC File Changes in v3.0
In DAC 2.0BACPAC added
BACPAC is DAC files + data (compressed JSON format)
In DAC 3.0Filenames/streams were refactoredDifferent XML Schema for moldel.xml and other streams
Supported Versions
SQL Server Version
DAC Feature 2000 2005 2008 2008 R2 2012 Azure
Extract DAC No Yes Yes Yes Yes Yes
Deploy DAC No SP4 SP2 Yes Yes Yes
Delete DAC No SP4 SP2 Yes Yes Yes
Register DAC No SP4 SP2 Yes Yes Yes
Upgrade DAC No SP4 SP2 Yes Yes No
Import BACPAC No SP4 SP2* Yes* Yes* Yes*
Export BACPAC No SP4 SP2* Yes* Yes* Yes*
SSMS Support No No No Yes(DAC v1) Yes Yes (2008 R2, 2012)
* BACPAC supported with SQL Server 2012 SSMS and SSDT
Working with DAC
SSDT Schema Compare can compare DACPACsCompare .dacpac to another .dacpac or to existing database/database projectSSDT available as a free web download
Standalone or integrates into existing VS2010 Pro or above installation
Support for headless environment:Install DAC tools without SSDT IDE
Install DACFramework.msi and dependencies form SQL Server 2012 Feature PackInstall SSDTBuildUtilities.msi for MSBuild/TeamBuild support
Working With DAC
Encapsulated in a set of librariesLegacy utility library is Microsoft.SqlServer.Management.Dac.dll
DACFx 3.0 assembly is Microsoft.SqlServer.Dac.dllPre-requisites
T-SQL ScriptDom Microsoft SQLCLR Types
Initial Deployment
Supply name of instance for deploymentProvide a database nameSet the publish options you wantPublish DACPAC
Database and objects are createdDatabase options are defined by the package
Registering Data-Tier Applications
Registering a DAC requiresdb_owner or better
Managing Data-Tier Applications
Entries made in msdb for installed DACsStored in master on SQL Azure
Must back upDatabase for DACmsdb
Modifying database name or deleting database will destroy association with dac history entries
No further upgrade via DACNo utilization reports in SQL Server Utility
Upgrading Data-Tier Applications
Upgrade Data-Tier Application WizardChanges schema and properties of deployed applicationsNew database created with new schema
DAC v1.0 - Data is migratedOriginal database set to read-onlyBoth databases then renamedMust consider space usage
DAC V1.1+ – Upgrade in placeAlter script generated at install timeDBAs can save the script and customize
Database Drift
Detects changes to registered DAC database since last deployment/registrationAllows changes to be incorporated into a new .dacpac or dropped
SSDT Schema Compare helps merge these changes into a database of project
DACFx and SQL Azure
DACFx v3.0 supports full surface area of SQL AzureIn SQL Azure
DAC information stored in SQL Azure master databaseCan Publish to SQL Azure from SSMS, SSDT or SqlPackage.exe
Used also by SQL Azure Portal
Additional DAC Operations
DAC 2.0+ can back up and move schema and dataSchema and data format known as BACPACData included in compressed JSON format
DACFX exposes Import and Export methodsAccessible in PowerShell/SqlPackage.exe/API
SQL Azure portal Import/ExportExport BACPAC to local or Windows Azure StorageImport BACPAC from local or Windows Azure StorageSSMS 2012 can export/import database using BACPAC
DACFx v3.0
DACFX v3.0 consumed by SSDT and SSMS 2012Target-specific model validation of database project performed at build timeSSDT supports incremental update and publish scenariosSSDT output is v3.0 DACPAC
SqlPackage.exe - command-line tool for DAC verbs
DACFx 3.0
In DACFx 3.0APIs updated to work with full range of DAC verbs
Microsoft.SqlServer.Dac namespace
Primary actions contained in DacServices class (not DacStore)Verbs to
Create and Deploy DACPACs/BACPACsGenerate T-SQL incremental update scriptsGenerate XML Drift and Deployment reports
Summary
DAC is a package format for database schema management
2.0 and above also can contain dataUsed for
Managing database schemaMoving database data
Used with SSMS, VS, SSDT, SQL Azure PortalsFunctionality depends on
Tool versionDatabase versionDACPAC/BACPAC version
References
SSDT Blog - http://blogs.msdn.com/b/ssdt/Using Data Tier Applications to Move and Manage SQL Azure Databases, SQL Server Magazine, Jan 2012Data-tier Application
SSDT:http://msdn.microsoft.com/en-us/data/gg427686
SQL Server 2012 Docshttp://msdn.microsoft.com/en-us/library/ee210546
Track Resources
@sqlserver@ms_teched
mvaMicrosoft Virtual Academy
SQL Server 2012 Eval Copy
Get Certified!
Hands-On Labs
Resources
Connect. Share. Discuss.
http://northamerica.msteched.com
Learning
Microsoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources for IT Professionals
http://microsoft.com/technet
Resources for Developers
http://microsoft.com/msdn
Complete an evaluation on CommNet and enter to win!
MS Tag
Scan the Tagto evaluate thissession now onmyTechEd Mobile
© 2012 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.