Sunday, January 31, 2016

windows azure cloud computing - Part 4 : SQL Azure database

 

Plan


Introduction

through this tutorial, you will learn how you can create an SQL Azure Database and how you can migrate from on-premises SQL Server Database to the Azure cloud.

Using the code

How to Create Azure Database ?

step 1 : connect to your Azure management portal.
step 2 : once connected, click on SQL Database item from Main Menu :

step 3 : click on add new database button :


step 4 : complete form details and click on create button after  completing the filling of data :


step 5 : create or select new server to assign it to your database :


step 6 : you will receive a successful notification after the good creation of database :


step 7 : refresh the SQL Database page to find your new Database :


How you can manage your Azure Database ?

step 1 : get you connection string.



step 2 :  install the latest Microsoft SQL Server, to be sure that you have the latest functionalities, in this tutorial , i downloaded SQL Server 2016 CTP from Microsoft official website.
step 3 : open your SQL Server Management Studio, and try to connect to your SQL Azure Server by entering the SQL Azure Server Name, user name (login) and password using the above authentication parameters :

step 3 : try to execute some SQL Server instructions on your Azure database :


 
 
the above T-SQL code example show you how you can create a table titled TestTable, and how you can insert and read rows.
drop table if EXISTS TestTable
go
create table TestTable(
_Id INT PRIMARY KEY,
_Name varchar(100),
);
insert into TestTable(_Id, _Name) values(0 , 'Name 1');
insert into TestTable(_Id, _Name) values(1 , 'Name 2');
select * from TestTable;




How to migrate an existing SQL Server Database to SQL Azure Database (PAAS) ?

In this section we will learn, how you can create your Azure Database from an existing SQL Server Database.
The below schema can show you the different ways to do the migration process :



In what follow, i will focus only on the first way to do the migrating of our on-premises SQL Server Database to Sql Azure through the .bacpac transformation using SQL Server Management Studio.

Export to Bacpac file :

step 1 : connect to your on premise SQL Server Database :


step 2 : create not empty table titled Test :

use TestMigrationSQLDB;
create table Test(
_ID int identity(1,1) PRIMARY KEY,
_FName varchar(10),
);
go
insert into Test (_FName) values('Omar');
insert into Test (_FName) values('Nasri');
select * from Test;    

Result :


 
 
step 3 : select Export Data-tier Application :



 
 
step 4 : chose your destination folder to store the .bacpac file. and click on next button :


 
 
step 4 : Once the operation is completed, you can open your destination export folder to verify the existence of .bacpac file :




Import from BACPAC File :

step 1 : add new connection to your SQL Azure Server Database.
step 2 : select Import Data-tier Application :


step 3 : select .bacpac file to import :


step 4 : enter a connection to a Azure SQL Database Server, and specify the features of your new Azure Database, and click on next button to start the import process :


step 7 : if the importation process is successfully done, you will find you database in your SQL AZURE SERVER Databases tree :


step 8 : you can also check if your database is well installed, through your Windows Azure management portal by opening the SQL Database Page :



Conclusion

In the next tutorial, we will explains to you step by step how you can migrate you asp.net web application to the  Azure website.

No comments:

Post a Comment