Daniel Calbimonte

How to export a local table to an Azure VM

March 31, 2015 by

Introduction

In my last chapter, How to migrate your database to an Azure Virtual Machine I showed you the steps to connect to a SQL Server in an Azure VM by using SQL Server Management Studio (SSMS). In this new chapter, we will show you how to work with SQL Server Integration Services (SSIS) to export a local table and its data to an Azure Virtual Machine (VM) with SQL Server installed.

These days, SSIS is a very important tool to automate tasks and create projects to import data from different data sources like Oracle, MySQL, and in this case MS Azure. With SSIS you can create friendly tasks visually, without programming knowledge, and create fast tasks to import and export data in parallel tasks (if necessary) with friendly tools.

This example is a step by step tutorial which does not require previous knowledge in SSIS, but requires previous knowledge from Azure from my Azure articles.

Requirements

You should be able to connect to the SQL Server in the Azure VM using your local SSMS. In order to enable the SSMS, read my article with the title How to connect to Azure from your local machine.

  1. You need an Azure VM with SQL Server installed and with a database.
  2. The SQL Server Data Tools (SSDT) for Business Intelligence installed in your local machine.
  3. A local SQL Server Database with a table to export (in this example a database name is SSIS and the table t1 and some data inside it).
  4. A database in the Azure VM machine where we will export the table (in this example the VM database name is also SSIS).

Getting Started

  1. First of all, we will create a SSIS project. In the SSDT, go to File>New project.


    Figure 1. The File Project

  2. Create an Integration Services Project. Go to Business Intelligence and select Integration Services Project.


    Figure 2. Integration Services Project.

  3. Drag and drop the Data Flow Task to the design pane and double click on the Data Flow Task. This task is used to export the data.


    Figure 3. The Data Flow Task

  4. In the Data Flow Tag, drag and drop the OLE DB Source Task. This task will be used to create a connection to a local SQL Server.


    Figure 4. The OLE DB Source

  5. Drag and drop the OLE DB destination task. This task will be used to create a connection to SQL Azure.


    Figure 5. The OLE DB Source and OLE DB Destination

  6. Now connect both tasks and double click on the OLE DB Source.


    Figure 6. Connecting tasks

  7. The OLE DB Source Editor window will be displayed. Press the New button.


    Figure 7. OLE DB Source Editor

  8. On the Configure OLE DB Connection Manager, press the New button to create a new connection.


    Figure 8. Configure OLE DB Connection

  9. Add the Server name of the local machine and the database with the table that you want to export to Azure and press OK. In this example, the database name is ssis


    Figure 9. Connection Manager.

  10. On the Configure OLE DB connection manager, press OK.


    Figure 10. Connection created.

  11. On the OLE DB Source Editor Window, in the Data Access mode, select the Table or view option. On the name of the table or the view, select the local table that you want to export (in this case, t1).


    Figure 11. The table t1.

  12. Double click on the OLE DB Destination. Press the New button to create a new OLE DB connection. By default, the Data Access mode is Table or view – fast load which is the fastest option to load data.


    Figure 12. The OLE DB Destination Editor

  13. On the Configure OLE DB Connection Manager, press the New button.


    Figure 13. Creating the Azure connection

  14. Keep the Native OLE DB\SQL Server Native Client. In the Server name text box, write the complete Azure VM name. Specify your credentials. In this example, it is the SQL Server credentials created and used in the previous article. Finally, select the Azure destination database.


    Figure 14. The SQL Azure credentials used

  15. Press the new button to create a new destination table to receive the data exported from the local machine.


    Figure 15. Creating a new table in azure

  16. Modify the table name. In this example, we will create a table named t1 in the azure machine.


    Figure 16. Creating the T-SQL for the Azure table

  17. Press the Mappings page. By default, if the name of the source and destination column are the same, the mapping will be automatically.


    Figure 17. Mapping the columns

  18. Press the Start button to initiate the package and export the data from the local table to Azure.


    Figure 18. Starting the package

  19. If everything is OK, the task will be marked with green icons and the number of rows exported will be displayed.


    Figure 19. The package executed

  20. Now in the SSMS, verify that the table and the data was created. In this example, we created a table t1 in the ssis database in the Azure Server.


    Figure 20. The table exported to Azure.

  21. Check the rows imported in the table using a select sentence.


    Figure 21. Select rows

  22. Now you can see the data imported from the local source table to the SQL Azure. As you can see, all the data is OK


    Figure 22. The data exported.

    Conclusion

    In this article, we show how to export a table and its data to an Azure Virtual Machine with SQL Server. As you can see, once you can connect to the Azure VM, the rest is a straightforward process. There is almost no difference between a SQL Server on a local network than a machine in Microsoft Azure.

    Daniel Calbimonte
    Latest posts by Daniel Calbimonte (see all)
168 Views