批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

批量关停azure vm

介绍 ( Introduction )

In this new article, we will create a SQL Server Report using SQL Server Reporting Services from a SQL Server machine installed in an Azure Virtual Machine. We will show step by step how to connect from a local machine to a VM Azure Database and generate a SQL report.

在这篇新文章中,我们将使用Azure虚拟机中安装SQL Server计算机中SQL Server Reporting Services创建SQL Server报告。 我们将逐步展示如何从本地计算机连接到VM ​​Azure数据库并生成SQL报告。

批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

要求 ( Requirements )

  • For the article, it is required the VM in Azure installed.

    对于本文,需要在Azure中安装VM
  • It will also be necessary the Azure subscription.

    也将需要Azure订阅。
  • You will also need a Virtual Machine in Azure with the SQL database installed on it (you can review our article about VM machines). We just need the Database installed.

    您还需要在Azure虚拟机上安装SQL数据库(您可以查看有关VM计算机的文章 )。 我们只需要安装数据库。
  • A Server with the Windows OS installed locally.

    在本地安装Windows操作系统的服务器。
  • The SQL Server Data Tools for business intelligence installed in the local machine to generate the SQL Server Reports.

    安装在本地计算机上的用于商业智能SQL Server数据工具可生成SQL Server报告。
  • The SQL Server installed in the local machine (specially the SSRS).

    安装在本地计算机(特别是SSRS)中SQL Server。
  • The Adventureworks database installed on the VM Azure machine or any other database with tables and data already created. In this article, we will use the Adventureworks2014 database.

    安装在VM Azure计算机上的Adventureworks数据库或具有表和数据的其他任何数据库。 在本文中,我们将使用Adventureworks2014数据库。
  • It will be necessary a SQL Endpoint on the portal.

    门户上必须有一个SQL端点。
  • The SQL Port needs to be enabled, and also the EndPoint rules should be enabled. You can check our article we will explain how to do it step by step.

    需要启用SQL端口,并且还应启用EndPoint规则。 您可以查看我们的文章,我们将逐步解释如何做。
  • The SQL Server authentication enabled in Azure.

    在Azure中启用了SQL Server身份验证。
  • A SQL Account and a SQL password in Azure.

    Azure中SQL帐户和SQL密码。

入门 ( Getting started )

  1. Open the SSDT for Business Intelligence or the Visual Studio and in the menu, go to File> New Project.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 1. The SSRS menu

    打开SSDT for Business Intelligence或Visual Studio,然后在菜单中转到“文件”>“新建项目”。


    图1. SSRS菜单
  2. Select the Report Server Project Wizard.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表


    Figure 2. The reporting service Wizard

    选择报表服务器项目向导。

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表


    2 报告服务向导
  3. The Welcome to the Report Wizard message will be displayed. Press next.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 3. The Welcome wizard

    将显示“欢迎使用报告向导”消息。 按下一步。


    3 欢迎向导
  4. To connect to the Azure Database, press the Edit button.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 4. The Data Source connection information

    若要连接到Azure数据库,请按“编辑”按钮。


    图4.数据源连接信息
  5. The server name is the name of the Azure VM. In this example, the name of the VM is olapsqldan.cloudapp.net. This name can be found in the Azure Portal. You will need to specify the SQL Server account created on the VM machine (in the requirements). Finally, we will specify the Database name. In this example, the database name is the Adventureworks2014. You can use other database from your preference.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 5. The connection information to Azure

    服务器名称是Azure VM的名称。 在此示例中,VM的名称为olapsqldan.cloudapp.net。 可以在Azure门户中找到该名称。 您将需要指定在VM计算机上创建SQL Server帐户(在要求中)。 最后,我们将指定数据库名称。 在此示例中,数据库名称为Adventureworks2014。 您可以根据自己的喜好使用其他数据库。


    图5.与Azure的连接信息
  6. Once the connection information is specified, press next.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 6. The credentials to Azure

    指定连接信息后,按下一步。


    图6. Azure的凭据
  7. You will be asked the SQL Server credential again. Once entered, press OK.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 7. The Data Source Credentials

    系统将再次询问您SQL Server凭据。 输入后,按确定。


    图7.数据源凭证
  8. The design the query window is used to write the query. You can write the query manually, copy and paste from other tools like the SQL Server Management Studio (SSMS) or use the Query Builder to create the query with friendly UI tools. We will press the Query Builder button in this example.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 8. The Query Builder

    设计查询窗口用于编写查询。 您可以手动编写查询,可以从其他工具(如SQL Server Management Studio(SSMS))复制和粘贴,也可以使用查询生成器通过友好的UI工具创建查询。 在此示例中,我们将按“查询生成器”按钮。


    图8.查询生成器
  9. In the query designer, press the option to add a table.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 9. Adding a table in the Query designer

    在查询设计器中,按选项以添加表。


    图9. 在查询设计器中添加一个表
  10. Select the Department table (or any table of your preference) and press the Add button.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 10. Selecting tables

    选择“部门”表(或您偏好的任何表),然后按“添加”按钮。


    图10. 选择表
  11. Select the columns that you want to be displayed in the report.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 11. Selecting columns

    选择要在报告中显示的列。


    图11.选择列
  12. If you have T-SQL knowledge, you could modify manually the queries done in steps 10 and 11. If not, just go to the next window.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 12. The query string

    如果您具有T-SQL知识,则可以手动修改在步骤10和11中完成的查询。否则,请转到下一个窗口。


    图12.查询字符串
  13. There are 2 options for the report type:

    1. Tabular, which will show the information in columns. This option has a fixed number of columns.
    2. Matrix, which will combine the information of rows and columns using dimensions. The number of columns depends on the results of the query.

    In this example, we will use the Tabular option.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 13. The report type

    报告类型有2个选项:

    1. 表格,将在列中显示信息。 此选项具有固定的列数。
    2. 矩阵,它将使用维度合并行和列的信息。 列数取决于查询结果。

    在此示例中,我们将使用“表格格式”选项。


    图13.报告类型
  14. You can separate or classify the reports in groups pages based on available fields. The next window will give us option to group the data and show which fields will be displayed. For example, we can create groups per groupname. In this example, we will use the default values and press next.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 14. The option to group data in reports

    您可以根据可用字段将报告分为组页面或进行分类。 下一个窗口将为我们提供将数据分组并显示要显示的字段的选项。 例如,我们可以按组名创建组。 在此示例中,我们将使用默认值,然后按下一步。


    图14.将数据分组到报表中的选项
  15. There are some few default styles in the report wizard. Slate, Forest, Corporate, Bold, Ocean and Generic. If you do not like any of these default reports, you can customize the reports later. In this example, we will use the Corporate style, but you can choose any other option. Once the style is chosen, press Next.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 15. The different table styles

    报告向导中有一些默认样式。 板岩,森林,企业,粗体,海洋和通用。 如果您不喜欢这些默认报告中的任何一个,则可以在以后自定义报告。 在此示例中,我们将使用“公司”样式,但是您可以选择任何其他选项。 选择样式后,按下一步。


    图15. 不同的表格样式
  16. The Completing the wizard will display all the option chosen. You can review and verify that the Datasource, connection string, report type, layout type, style, details and the query are OK. Additionally, you can check the Preview report option to see a Preview of the report directly. In this example, we are going to enable this option. Once selected, press Finish.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 16. The last option of the wizard

    “正在完成”向导将显示所有选择的选项。 您可以查看并验证数据源,连接字符串,报告类型,布局类型,样式,详细信息和查询是否正常。 此外,您可以选中“预览报告”选项以直接查看报告的预览。 在此示例中,我们将启用此选项。 选择后,按完成。


    图16.向导的最后一个选项
  17. In this example, we are using the SQL Authentication to connect to the VM Azure Database. The report will ask the credentials of the step 5. Once the SQL login and the password is specified, execute the report.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    Figure 17. The login and password requests

    在此示例中,我们使用SQL身份验证连接到VM ​​Azure数据库。 该报告将询问步骤5的凭据。一旦指定了SQL登录名和密码,请执行该报告。


    图17.登录名和密码请求
  18. Once finished, you will have your report ready. You can edit, export to pdf, word, Excel or other formats of your preference.

    批量关停azure vm_如何从Azure VM数据库运行本地SQL报表

    完成后,您将准备好报告。 您可以编辑,导出为pdf,word,Excel或您喜欢的其他格式。

结论 ( Conclusion )

As you can see, once you can connect to the VM in Azure the process to create local reports is very simple. You can work as a local database. The Internet speed will make the difference. If you need to work with large reports and your Internet connection is not fast enough, it can be a problem. However, besides the internet speed, you do not have restrictions. You can create charts, maps, KPIs or any other feature of your preference.

如您所见,一旦可以连接到Azure中的VM,创建本地报告的过程就非常简单。 您可以作为本地数据库。 互联网速度将有所作为。 如果您需要处理大型报表,并且Internet连接速度不够快,则可能会出现问题。 但是,除了互联网速度外,您没有任何限制。 您可以创建图表,地图,KPI或您喜欢的任何其他功能。

Once you have the connection to the Azure VM, the process to create reports is the same as a simple local report.

连接到Azure VM后,创建报告的过程与简单的本地报告相同。

翻译自: https://www.sqlshack.com/how-to-run-a-local-sql-report-from-an-azure-vm-database/

批量关停azure vm