批量关停azure vm_如何将本地表导出到Azure VM
批量关停azure vm
介绍 ( 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.
在上一章“ 如何将数据库迁移到Azure虚拟机”中,我向您展示了使用SQL Server Management Studio(SSMS)连接到Azure VM中SQL Server的步骤。 在这一新的章节中,我们将向您展示如何使用SQL Server Integration Services(SSIS)将本地表及其数据导出到已安装SQL Server的Azure虚拟机(VM)。
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.
如今,SSIS是一个非常重要的工具,可以自动执行任务并创建项目以从不同的数据源(如Oracle,MySQL,在本例中为MS Azure)导入数据。 使用SSIS,您无需编程知识即可直观地创建友好的任务,并使用友好的工具创建快速任务以在并行任务中导入和导出数据(如有必要)。
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.
本示例是一个分步教程,不需要SSIS的先前知识,但需要Azure文章中Azure的先前知识。
要求 ( 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.
您应该能够使用本地SSMS连接到Azure VM中SQL Server。 为了启用SSMS,请阅读标题为“如何从本地计算机连接到Azure”的文章。
- You need an Azure VM with SQL Server installed and with a database. 您需要安装了SQL Server和数据库的Azure VM。
- The SQL Server Data Tools (SSDT) for Business Intelligence installed in your local machine. 安装在本地计算机上的用于商业智能SQL Server数据工具(SSDT)。
- 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). 具有要导出表的本地SQL Server数据库(在此示例中,数据库名称为SSIS,表名为t1,表中还有一些数据)。
- A database in the Azure VM machine where we will export the table (in this example the VM database name is also SSIS). 我们将在其中导出表的Azure VM计算机中的数据库(在此示例中,VM数据库名称也是SSIS)。
入门 ( Getting Started )
-
First of all, we will create a SSIS project. In the SSDT, go to File>New project.
Figure 1. The File Project首先,我们将创建一个SSIS项目。 在SSDT中,转到“文件”>“新建项目”。
图1.文件项目 -
Create an Integration Services Project. Go to Business Intelligence and select Integration Services Project.
Figure 2. Integration Services Project.创建一个Integration Services项目。 转到商业智能,然后选择Integration Services项目。
-
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将数据流任务拖放到设计窗格中,然后双击数据流任务。 此任务用于导出数据。
图3.数据流任务 -
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在数据流标签中,拖放OLE DB源任务。 此任务将用于创建与本地SQL Server的连接。
图4. OLE DB源 -
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拖放OLE DB目标任务。 此任务将用于创建与SQL Azure的连接。
图5. OLE DB 源 和OLE DB目标 -
Now connect both tasks and double click on the OLE DB Source.
Figure 6. Connecting tasks现在连接两个任务,然后双击OLE DB源。
图6.连接任务 -
The OLE DB Source Editor window will be displayed. Press the New button.
Figure 7. OLE DB Source Editor将显示“ OLE DB源编辑器”窗口。 按“新建”按钮。
图7. OLE DB源编辑器 -
On the Configure OLE DB Connection Manager, press the New button to create a new connection.
Figure 8. Configure OLE DB Connection在“配置OLE DB连接管理器”上,按“新建”按钮以创建新的连接。
图8. 配置OLE DB连接 -
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.添加要导出到Azure的表的本地计算机和数据库的服务器名称,然后按OK。 在此的示例数据库名称是sis
图9.连接管理器。 -
On the Configure OLE DB connection manager, press OK.
Figure 10. Connection created.在“配置OLE DB连接管理器”上,按OK。
图10.创建的连接。 -
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.在“ OLE DB源编辑器”窗口上,在“数据访问”模式下,选择“表”或“视图”选项。 在表或视图的名称上,选择要导出的本地表(在本例中为t1)。
图11.表t1。 -
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双击OLE DB目标。 按“新建”按钮创建一个新的OLE DB连接。 默认情况下,数据访问模式为表或视图–快速加载,这是加载数据的最快选项。
图12. OLE DB目标编辑器 -
On the Configure OLE DB Connection Manager, press the New button.
Figure 13. Creating the Azure connection在“配置OLE DB连接管理器”上,按“新建”按钮。
图13. 创建Azure连接 -
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保留本机OLE DB \ SQL Server本机客户端。 在“服务器名称”文本框中,输入完整的Azure VM名称。 指定您的凭据。 在此示例中,这是上一篇文章中创建和使用SQL Server凭据。 最后,选择Azure目标数据库。
图14.使用SQL Azure凭据 -
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按new按钮创建一个新的目标表,以接收从本地计算机导出的数据。
图15.在azure中创建一个新表 -
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修改表名称。 在此示例中,我们将在azure机器中创建一个名为t1的表。
图16.为Azure表创建T-SQL -
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按“映射”页面。 默认情况下,如果源列和目标列的名称相同,则映射将自动进行。
图17 。 映射列 -
Press the Start button to initiate the package and export the data from the local table to Azure.
Figure 18. Starting the package按“开始”按钮以启动程序包,并将数据从本地表导出到Azure。
图18.启动软件包 -
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如果一切正常,该任务将用绿色图标标记,并显示导出的行数。
图19.执行的包 -
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.现在在SSMS中,验证是否已创建表和数据。 在此示例中,我们在Azure服务器的ssis数据库中创建了一个表t1。
图20.将表导出到Azure。 -
Check the rows imported in the table using a select sentence.
Figure 21. Select rows使用选择语句检查表中导入的行。
图21.选择行 -
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.
现在,您可以看到从本地源表导入到SQL Azure的数据。 如您所见,所有数据都可以
图22.导出的数据。在本文中,我们展示了如何使用SQL Server将表及其数据导出到Azure虚拟机。 如您所见,一旦可以连接到Azure VM,剩下的就是一个简单的过程。 本地网络上SQL Server与Microsoft Azure中的计算机之间几乎没有区别。
翻译自: https://www.sqlshack.com/how-to-export-a-local-table-to-an-azure-vm/
批量关停azure vm