SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web...

44
Hands-On Lab SQL Azure Data-tier Applications Lab version: 1.0.0 Last updated: 4/19/2022 Page 1

Transcript of SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web...

Page 1: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Hands-On LabSQL Azure Data-tier ApplicationsLab version: 1.0.0

Last updated: 5/20/2023

Page 1

Page 2: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

CONTENTS

OVERVIEW................................................................................................................................................. 3

EXERCISE 1: DEPLOYING DATA-TIER APPLICATIONS TO A SQL AZURE DATABASE....................5Task 1 – Creating SQL Server Database Project...................................................................................5

Task 2 – Creating Database Schema....................................................................................................7

Task 3 – Publishing the Database to SQL Azure.................................................................................11

Verification........................................................................................................................................14

EXERCISE 2: UPGRADING DATA-TIER APPLICATIONS IN SQL AZURE...........................................16Task 1 – Extracting a Data-Tier Application File from SQL Azure.......................................................16

Task 2 – Importing a DAC Package in SSDT........................................................................................18

Task 3 – Updating the database schema in a Database Project.........................................................22

Task 4 – Deploying the Upgraded DAC Package................................................................................26

Verification........................................................................................................................................30

SUMMARY................................................................................................................................................ 33

APPENDIX A: CREATING A SQL AZURE SERVER...............................................................................33Task 1 – Retrieving your SQL Azure Server Name..............................................................................33

Page 2

Page 3: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Overview

SQL Azure Database supports a variety of mechanisms for deploying, versioning and migrating databases. You can use the traditional Transact-SQL script based approach to create your database objects, then populate your data either using scripts, BCP or SQL Server Integration Services. Schema upgrade scripts tend to be either hand coded or generated using additional tools. This approach is well known by SQL Server developers, but can be tedious for developers who are new to SQL Azure, especially when dealing with the complexities associated with database schema versioning.

Microsoft is addressing this complexity with a new framework called the Data-tier Application Framework, or DAC Fx, which makes it much easier to deploy, migrate and version your database schemas for SQL Server and SQL Azure. DAC Fx shipped initially with SQL Server 2008 R2, and support was soon added for SQL Azure. Since then, DAC Fx has evolved significantly and is an important part of the developer and managability story for SQL Azure. It is being integrated into developer tools like the SQL Server Data Tools, management tools like SQL Server 2012 Management Studio, and as a service accessible from the Windows Azure Management Portal.

Objectives

In this hands-on lab, you will learn how to:

Create a new SQL Server project using SQL Server Data Tools (known as SSDT) to target SQL Azure.

Publish a Data-tier Application to SQL Azure using SQL Server 2012 Management Studio.

Extract a .dacpac file from a SQL Azure database, using SQL Server 2012 Management Studio.

Import a .dacpac file in SSDT and update the schema.

Upgrade a Data-tier Application in SQL Azure using the updated .dacpac file.

Prerequisites

You must have the following items to complete this lab:

Microsoft.NET Framework 4

SQL Server 2012 Management Studio

SQL Server Data Tools

Page 3

Page 4: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Exercises

This hands-on Lab includes the following exercises:

1. Deploying Data-tier Applications to a SQL Azure Database

2. Upgrading Data-tier Applications in SQL Azure

Estimated time to complete this lab: 45 minutes.

Page 4

Page 5: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Exercise 1: Deploying Data-tier Applications to a SQL Azure Database

In this exercise, you will learn how to create a new SQL Server Database project in SSDT, create a database definition schema and deploy it to SQL Azure.

Note: In order to complete this lab you will need a SQL Azure server to host the database. If you do not have one server created yet, use this appendix as a guide to do it: Appendix A: Creating a SQL Azure Server. Make sure you added the necessary Firewall Rules to allow you access to the SQL Azure Server using Management Studio. Also add the Microsoft Services rule (IP Address range “0.0.0.0” to “0.0.0.0”)

Additionally, if this is not the first time you run this exercise, you will need to run Reset.cmd script within the Source folder of this lab in order to clean up the SQL Azure database status. The script will prompt you for several pieces of information including a database name, which is “BooksInventory”.

Task 1 – Creating SQL Server Database Project

In this task you will create a SQL Server Database Project and set its target platform to SQL Azure.

1. Open SSDT. To do this, in Start | All Programs, click the Microsoft SQL Server Data Tools shortcut.

2. From the File menu, choose New and then Project.

3. In the New Project dialog, select SQL Server in the Installed Templates list. Choose the SQL Server Database Project template, set the Name of the project to BooksInventory, set the location to \Source\Ex01-DeployingDACApp, change the solution name to Begin, and ensure that Create directory for solution is checked. Click OK to create the project.

Note: Make sure your project name is BooksInventory, as this is required in this lab to perform an upgrade to the database.

Page 5

Page 6: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 1Create SQL Server Database Project

4. You will update the project’s Target Platform and the Output Type. To do this, in Solution Explorer, right-click the BooksInventory project node, select Properties.

5. In the Project Settings tab, change the Target Platform to SQL Azure and make sure that the option Create additional down-level .dacpac file (v2.0) within Output Types is checked.

Page 6

Page 7: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 2Configuring SQL Server Database Project

6. Press Ctrl + S to apply changes.

Note: You can set the target platform for your database project to any release of SQL Server 2005 or above or SQL Azure.

By doing so, you can centralize your database development in one project, but publish it to multiple SQL Server platforms as the need arises.

SSDT also makes this task simple by being aware of your target platform and automatically detecting any error in your code (e.g., when you are using unsupported features for a project that is going to be published to SQL Azure).

For more information about this refer to MSDN.

Task 2 – Creating Database Schema

Page 7

Page 8: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

In this task you will create the database schema that will be deployed to SQL Azure at the end of this exercise.

1. Add a new table to the Database project. To do this, right click in the BooksInventory project node, select Add and click Table.

Figure 3Add Table

2. In the Add New Item dialog, make sure Table template is selected and set the name to Authors. Click Add to create the table script.

Figure 4Create Table

Page 8

Page 9: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

3. In the BooksInventory node, within the Solution Explorer, double-click the Authors table we created in the previous step.

Figure 5Open Table Designer

4. In the Design tab within the Table Designer, add the following fields to the Authors table:

Name Data Type Allow Nulls? Is Primary Key?

Id Int No Yes

FirstName

nvarchar(50) No No

LastName

nvarchar(50) No No

5. Press Ctrl + S to apply changes.

6. Create a new table. To do this, repeat the first step of this task. This time, set the table name to Books and add the following fields:

Name Data Type Allow Nulls? Is Primary Key?

Id int No Yes

Title nvarchar(50) No No

ISBN nvarchar(13) Yes No

Price float Yes No

AuthorId int No No

Page 9

Page 10: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

7. Add a Foreign Key to the Books table. To do this, in the Table Designer, right-click the Foreign Keys node at the right pane and select Add New Foreign Key. Set its name to FK_Books_ToAuthors.

Figure 6Adding the Authors Foreign Key

8. To associate your Foreign Key to the Primary Key located in the Authors table, switch to the T-SQL tab and replace the CONSTRAINT line with the following highlighted code.

T-SQL

CREATE TABLE [dbo].[Books]( [Id] INT NOT NULL PRIMARY KEY, [Title] VARCHAR(50) NOT NULL, [ISBN] VARCHAR(13) NULL, [Price] FLOAT NULL, [AuthorId] INT NOT NULL, CONSTRAINT [FK_Books_ToAuthors] FOREIGN KEY ([AuthorId]) REFERENCES [Authors]([Id]))

9. Press Ctrl + S to apply changes.

10. Right-click the BooksInventory project node in the Solution Explorer and select Build.

11. After the build is completed, right-click again the BooksInventory project node in the Solution Explorer and select Open Folder in Windows Explorer. Browse to the Bin folder and then to Debug. Inside the folder, you will see 2 dacpac files that were generated in the previous step (one with the 2.5 schema version and the other one with the 2.0 version which is compatible with SQL Azure).

Page 10

Page 11: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 7Generated dacpac files in Bin folder

Task 3 – Publishing the Database to SQL Azure

In this task, you will use SQL Server Management Studio (SSMS) to deploy the database project to SQL Azure.

1. Open SSMS. To do this, in Start | All Programs | Microsoft SQL Server 2012 RC0, click the SQL Server Management Studio shortcut.

2. In the Connect to Server dialog, enter your SQL Azure server name and your credentials. Click Connect.

Figure 8Connecting to SQL Azure Server

3. In the Object Explorer panel, expand the Management node. Right click the Data-tie Applications node and select Deploy Data-tier Application.

Page 11

Page 12: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 9Deploying a Data-tier Application

4. In the Deploy Data-tier Application dialog, click Next. Click Browse and browse to the folder where the dacpac were generated. Select the dacpac file with the 2.0 suffix at the end. The DAC Details fields will show the values of the dacpac metadata. Click Next.

Page 12

Page 13: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 10Selecting a DAC package

5. Leave the default value, BooksInventory, in the name of the deployed DAC and database. Click Next. In the summary page, click Next. The deployment process will start.

6. Once the deployment process is completed, click Finish.

Page 13

Page 14: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 11DAC deployment process completed

Verification

In this task you will verify that the DAC package was successfully published to SQL Azure. To do this, you will explore the SQL Azure databases using the SQL Server Object Explorer that is included with SSDT.

1. Go back to SSDT. If not opened, in Start | All Programs, click the Microsoft SQL Server Data Tools shortcut

2. In the View menu, select SQL Server Object Explorer.

3. In the SQL Server Object Explorer pane, right-click the SQL Server node and select Add SQL Server. It will prompt a Connect to Server dialog. Fill it with your Server Name and Credentials and click Connect.

Page 14

Page 15: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 12Connecting to SQL Azure Server

4. Locate your SQL Azure Server and expand Databases folder. Locate the BooksInventory database we created in the previous task.

5. Expand Tables folder within BooksInventory database and verify that both Authors and Books tables were created.

Figure 13BooksInventory Verification

6. To see the DAC metadata registration, expand the Management node and the Data-tier Applications.

Figure 14Visualizing registered DAC Packages

Page 15

Page 16: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

7. Right-click the BooksInventory DAC and select Properties. You can view the DAC metadata registered in SQL Azure.

Figure 15Visualizing DAC metadata

Exercise 2: Upgrading Data-tier Applications in SQL Azure

In this exercise, you will extract a Data-Tier Application Component (DAC) from your SQL Azure Database, apply some changes in SSDT and publish the DAC back to the SQL Azure database.

Note: This exercise requires the database that is created in the Exercise 1.

Task 1 – Extracting a Data-Tier Application File from SQL Azure

In this task, you will extract a Data-Tier Application file from a SQL Azure database using SQL Server Management Studio. The extracted dacpac file will be used in SSDT to perform updates to your database.

1. Open SSMS. To do this, in Start | All Programs | Microsoft SQL Server 2012 RC0, click the SQL Server Management Studio shortcut.

2. In the Connect to Server dialog, enter your SQL Azure server name and your credentials. Click Connect.

Page 16

Page 17: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 16Connecting to SQL Azure Server

3. In the Object Explorer panel, expand the Databases node of your SQL Azure server. Right-click the BooksInventory, select Tasks, Extract Data-tier Application.

Figure 17Extracting a Data-tier Application

Page 17

Page 18: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

4. In the Extract Data-tier Application dialog, click Next.

5. Leave the DAC properties fields as they are and select a destination path for the extracted dacpac file clicking the Browse button. Click Next.

6. Wait until the Building the DAC package process is finished. Click Finish.

Figure 18Creating and saving the DAC package file

Task 2 – Importing a DAC Package in SSDT

In this Task, you will import the previously extracted DAC package to SSDT and change the database schema and DAC metadata information.

Page 18

Page 19: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

1. Open SSDT. To do this, in Start | All Programs, click the Microsoft SQL Server Data Tools shortcut.

2. From the File menu, choose New and then Project.

3. In the New Project dialog, select SQL Server in the Installed Templates list. Choose the SQL Server Database Project template, set the Name of the project to BooksInventory, set the location to \Source\Ex02-UpdatingDACApp, change the solution name to Begin, and ensure that Create directory for solution is checked. Click OK to create the project.

Note: Make sure your project name is BooksInventory, as this is required in this lab to perform an upgrade to the database.

Figure 19Create SQL Server Database Project

4. Right-click the BooksInventory project node, select Import and Data-tier Application (*.dacpac).

Page 19

Page 20: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 20Importing a Data-tier Application file

5. In the Import Data-tier Application File dialog, click Browse to select the previously extracted DAC package file. Make sure that Import Permissions and Import database settings options are checked, and the Folder structure is set to None. Click Start.

Figure 21Selecting the DAC package file and settings

6. Click Finish when the import process is completed. You will end up with a solution structure like the following:

Page 20

Page 21: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 22Imported Objects in Solution Explorer

7. Your project now contains two new files, which are the tables you created in the Exercise 1 of this lab. Before changing the database schema, you will update the project’s Target Platform and the Output Type. To do this, in Solution Explorer, right-click the BooksInventory project node, select Properties.

8. In the Project Settings tab, change the Target Platform to SQL Azure and make sure that the option Create additional down-level .dacpac file (v2.0) within Output Types is checked.

Figure 23

Page 21

Page 22: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Configuring SQL Server Database Project

9. Click the DAC Properties button.

10. In the Data-tier Application Properties dialog, leave the Name field as BooksInventory, change the Version to 1.1.0.0 and set the Description field to Upgraded Database. Click OK.

Figure 24Setting the DAC package properties

11. Press Ctrl + S to apply changes.

Task 3 – Updating the database schema in a Database Project

In this task, you will you will apply some changes to the database schema.

1. Add a new table. To do this, right click in the BooksInventory project node, select Add and click Table.

Page 22

Page 23: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 25Add Table

2. In the Add New Item dialog, make sure the Table template is selected and set the name to Genders. Click Add to create the table script.

Figure 26Creating the Genders Table

3. In the Solution Explorer, double-click the Genders table script we created in the previous step.

Page 23

Page 24: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

4. In the Design tab within the Table Designer, add the following fields to the Genders table:

Name Data Type Allow Nulls? Is Primary Key?

Id Int No Yes

Description

nvarchar(50) No No

5. Select the <unnamed> key from the right panel and press F4. The Properties panel will appear.

6. Set the Is Clustered property value to False.

7. Press Ctrl + S to apply changes.

8. Press CTRL+SHIFT+B to build the Solution. The Error List pane will appear showing a warning related to the new Genders table. This occurs because SSDT is validating the table schema against the target platform and detects statements which are incompatible in SQL Azure. This is useful to detect incompatibility issues between different platforms. In this case, the Genders table uses a nonclustered index, which is not supported by SQL Azure.

Figure 27Statement Options not supported in SQL Azure

9. Now, you will fix these statements. Double-click the Genders table script in the Solution Explorer and remove the NONCLUSTERED statement. Press CTRL+S to save the file.

10. Also, open the Authors and Books tables and remove the error marked statements. These are ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON and PAD_INDEX = OFF.

11. In the Solution Explorer, double-click the Authors table script.

12. In the Table Designer, add a new field named GenderId as int.

13. Add a Foreign Key to the Genders table. To do this, in the Table Designer, right-click the Foreign Keys node at the right pane and select Add New Foreign Key. Set its name to FK_Authors_Genders.

Page 24

Page 25: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 28Adding the Genders Foreign Key

14. To associate your Foreign Key to the Primary Key located in the Genders table, switch to the T-SQL tab and replace the CONSTRAINT line with name [FK_Authors_Genders] with the following highlighted code.

T-SQL

CREATE TABLE [dbo].[Authors] ( [Id] INT NOT NULL, [FirstName] VARCHAR (50) COLLATE Latin1_General_CI_AS NOT NULL, [LastName] VARCHAR (50) COLLATE Latin1_General_CI_AS NULL, [GenderId] INT NULL, CONSTRAINT [PK__Authors__42d35aa04fc8def8a5e4] PRIMARY KEY CLUSTERED ([Id]) WITH (IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF), CONSTRAINT [FK_Authors_Genders] FOREIGN KEY ([GenderId]) REFERENCES [Genders]([Id]))GO

15. Press Ctrl + S to apply changes.

16. Right-click the BooksInventory project node and select Build.

17. After the build is completed, right-click again the BooksInventory project node in the Solution Explorer and select Open Folder in Windows Explorer. Browse to the Bin folder and then to Debug. Inside the folder, you will see 2 dacpac files that were generated in the previous step (one with the 2.5 schema version and the other one with the 2.0 version which is compatible with SQL Azure).

Page 25

Page 26: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 29Generated dacpac files in Bin folder

Task 4 – Deploying the Upgraded DAC Package

In this task, you will publish the upgraded DAC package using the SQL Server Management Studio.

1. Open SSMS. To do this, in Start | All Programs | Microsoft SQL Server 2012 RC0, click the SQL Server Management Studio shortcut.

2. In the Connect to Server dialog, enter your SQL Azure server name and your credentials. Click Connect.

Figure 30Connecting to SQL Azure Server

3. In the Object Explorer panel, expand the Management node and the Data-tie Applications node. Right-click the BooksInventory DAC and select Upgrade Data-tier Application.

Page 26

Page 27: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 31Upgrading a Data-tier Application

4. In the Upgrade Data-tier Application dialog, click Next. Click Browse and browse to the folder where the dacpac were generated in the previous task. Select the dacpac file with the 2.0 suffix at the end. The DAC Details fields will show the values of the dacpac metadata you entered in previous tasks. Click Next.

Page 27

Page 28: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 32Selecting a Data-tier Application and showing the updated details

5. In the Detect Change page click Next after the comparison is completed.

6. Click the Rollback on failure option. If the upgrade process fails, no changes will be applied. Click Next.

7. In the Review the upgrade plan page, you will see the different changes that will be applied to the SQL Azure database. Check that the new Genders table and a new element for the Authors table are present in the list. Click Next.

Page 28

Page 29: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 33Reviewing the Upgrade Plan

8. In the Summary page, click Next.

9. Click Finish once the upgrading process is completed.

Page 29

Page 30: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 34Upgrading the DAC

Verification

In this task you will connect to the SQL Azure Server to verify that the DAC and associated database were correctly upgraded. To do this, you will use the SQL Server Object Explorer that SSDT provides.

1. Go back to SSDT. If not opened, in Start | All Programs, click the Microsoft SQL Server Data Tools shortcut

2. In the View menu, select SQL Server Object Explorer.

Page 30

Page 31: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

3. In the SQL Server Object Explorer pane, right-click the SQL Server node and select Add SQL Server. It will prompt a Connect to Server dialog. Fill it with your Server Name and Credentials and click Connect.

Figure 35Connecting to SQL Azure Server

4. Locate your SQL Azure Server and expand Databases folder. Locate the BooksInventory database.

5. Expand Tables folder within BooksInventory database and verify that there is a new table named Genders, and that the Authors table has a new column as foreign key named GenderId.

Page 31

Page 32: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 36DAC Upgrade Verification

6. Check if the metadata was updated correctly. To do this, in the SQL Server Object Explorer, expand the Management folder within your SQL Azure server node.

7. Expand Data-tier Applications node and select BooksInventory node.

Figure 37DAC Metadata

8. Right-click the BooksInventory DAC and select Properties. Check that the current version and description of BooksInventory values are the one you set when updating the DAC properties.

Page 32

Page 33: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 38DAC Metadata Upgrade Verification

Summary

In this Lab you learned how to create a new SQL Server Database Project using SSDT and to deploy it to SQL Azure using the SQL Server Management Studio. Also you learned how to extract a DAC definition file using SQL Server Management Studio, and how to upgrade it in SSDT to finally publishing back the new changes.

Appendix A: Creating a SQL Azure Server

In this appendix you will learn how to connect to your SQL Azure account and create a database server, add a new user and then reconnect to SQL Azure so that you can begin working with your new server.

Task 1 – Retrieving your SQL Azure Server Name

In this exercise, you will log into the Windows Azure Management Portal to create a new SQL Azure server to your account.

1. Open Internet Explorer and navigate to the Windows Azure portal at https://windows.azure.com.

2. Log in to your Windows Live account.

Page 33

Page 34: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 39Logging into the Azure Services Portal

3. At the Windows Azure portal home page, click New Database Server on the ribbon.

Figure 40Creating a new SQL Azure database server

Page 34

Page 35: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

4. Select your subscription on the left pane. Click Create on the Server ribbon.

Figure 41Creating a new SQL Azure database server

5. Select a region from the Region drop down list, and then click Next. The location determines which datacenter the database will reside in.

Page 35

Page 36: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 42Choosing region

6. Enter an administrator account name and password and click Next.

Page 36

Page 37: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 43Entering administrator login and password

Note: An administrator account is a master account used to manage the new server. You should avoid using this account in connection strings where the username and password may be exposed.

The password policy requires that the password follow certain rules.

Page 37

Page 38: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

7. Click Finish to create the new server. You will configure firewall rules later on this exercise.

Figure 44Firewall rules dialog

8. Finally, the new server information, including Fully Qualified Server Name, is shown.

Page 38

Page 39: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

Figure 45SQL Azure projects list

Note: The fully qualified domain name of the server uses the following format:

<ServerName>.database.windows.net

where <ServerName> identifies the server, for example, a9ixtp7pux.database.windows.net.

9. Expand the subscription node located on the left pane and click on the server name you have created. The Server Information page allows you to perform basic administration of the database server.

Figure 46

Page 39

Page 40: SQL Azure Data-tier Applicationsaz12722.vo.msecnd.net/.../labs/sqlazuredac1-0-1/Lab.docx  · Web viewSQL Azure Database supports a variety of mechanisms for deploying, versioning

SQL Azure server information page

10. The Firewall Rules allows you to specify a list of IP addresses that can access your SQL Azure Server. The firewall will deny all connections by default, so be sure to configure your allow list so that existing clients can connect to the server.

Note: Make sure you added the necessary Firewall Rules to allow you access to the SQL Azure Server using Management Studio. Also add the Microsoft Services rule (IP Address range “0.0.0.0” to “0.0.0.0”)

Figure 47Configuring the firewall settings for SQL Azure

Note: Changes to your firewall settings can take some time to become effective.

You now have a database server created and ready for the next steps in this lab. This database can be reached from anywhere in the world.

Page 40