批量关停azure vm

介绍 ( Introduction )

In this new article, we will use Visual Studio to connect to a SQL Server Database Installed in a Virtual Machine in Azure.

在这篇新文章中,我们将使用Visual Studio连接到安装在Azure虚拟机中SQL Server数据库。

Visual Studio is one of the most popular development tools in the world and connecting to Azure with Visual Studio is a very common need.

Visual Studio是世界上最受欢迎的开发工具之一,通过Visual Studio连接到Azure是非常普遍的需求。

We will modify an existing SQL Server table in Azure from Visual Studio. Later we will create a stored procedure and finally, we will create an inline table-valued function.

我们将从Visual Studio修改Azure中现有SQL Server表。 稍后,我们将创建一个存储过程,最后,我们将创建一个内联表值函数。

要求 ( Requirements )

  • An Azure subscription.Azure订阅 。
  • A virtual machine in Azure with SQL Server Installed.Azure中已安装SQL Server的虚拟机 。
  • Adventureworks example database installed in the VM.Adventureworks示例数据库 。
  • Visual Studio 2015 was used.Visual Studio 2015 。
  • the migrate Azure chapter.“迁移Azure”一章 。

入门 ( Getting started )

  1. In the Azure portal, select Browse All➜Virtual machines and select the Virtual Machine with SQL Server installed.

    在Azure门户中 ,选择“浏览所有”➜“虚拟机”,然后选择安装了SQL Server的虚拟机。

    Figure 1. Virtual Machines in Azure图1. Azure中的虚拟机

  2. Copy the Machine name which is also the SQL Server name (if you are using the default instance).

    复制计算机名称,该名称也是SQL Server名称(如果使用的是默认实例)。

    Figure 2. The Server Name in Azure 图2 Azure中的服务器名称

  3. Click on Server Explorer and in Data Connection, select Add Connection.

    单击服务器资源管理器,然后在数据连接中,选择添加连接。

    Figure 3. Adding a new connection图3.添加一个新的连接

  4. Use the server name of the step 2, unless the SQL Server instance is not a default instance of SQL Server and specify the SQL Server Authentication user name and password. Finally, write the Database name. In this example, we will use the AdventureWorks2014 database.

    除非SQL Server实例不是SQL Server的默认实例,否则请使用步骤2的服务器名称,并指定SQL Server身份验证用户名和密码。 最后,输入数据库名称。 在此示例中,我们将使用AdventureWorks2014数据库。

    Figure 4. Connection information图4.连接信息

  5. In order to see the connection, press the refresh button and you will be able to see the new connection

    为了查看连接,请按刷新按钮,您将能够看到新的连接

    Figure 5. Refreshing connection图5.刷新连接

  6. To view the data of the table, right click on it and select Show Table Data.

    要查看表的数据,请右键单击它,然后选择“显示表数据”。

    Figure 6. Showing Table Data图6.显示表数据

  7. You will be able to see the table data.

    您将能够看到表格数据。

    Figure 7. The Department information图7.部门信息

  8. To insert new data, go to the last row and write new data. In this example, we are adding the IT department.

    要插入新数据,请转到最后一行并写入新数据。 在此示例中,我们将添加IT部门。

    Figure 8. Adding data to the table图8.将数据添加到表

  9. In order to verify that the new data was added, connect to your VM in Azure.

    为了验证是否添加了新数据,请连接到Azure中的VM。

    Figure 9. Azure VM connection图9. Azure VM连接

  10. Open the SQL Server Management Studio

    打开SQL Server Management Studio

    Figure 10. SQL Server Management Studio图10. SQL Server Management Studio

  11. Verify that the table has the new data.

    验证该表具有新数据。

    Figure 11. 图11. Reviewing the table data查看表数据

  12. You will notice that the new row created on step 8 was successfully added.

    您将注意到在步骤8中创建的新行已成功添加。

    Figure 12. Verification of the insert in the VM Azure table图12.验证VM Azure表中的插入

  13. Now, we are going to create a stored procedure with a parameter. In Visual Studio, right click on Stored Procedures and select Add New Stored Procedure.

    现在,我们将创建带有参数的存储过程。 在Visual Studio中,右键单击“存储过程”,然后选择“添加新的存储过程”。

    Figure 13. 图13. Adding a new stored procedure添加一个新的存储过程

  14. By default, you will have this code:

    默认情况下,您将具有以下代码:

    Figure 14. Stored procedure code by default图14.默认情况下的存储过程代码

  15. In this example, we will create a stored procedure that will show the department information if we specify the name of the department. The @name will be the parameter with is the name of the department. The code will be like this:

    在此示例中,我们将创建一个存储过程,如果我们指定部门名称,该存储过程将显示部门信息。 @name将是带有部门名称的参数。 代码将如下所示:

    
    CREATE PROCEDURE [dbo].[departmentinfo]@name nvarchar(30)AS
    SELECT [DepartmentID],[Name],[GroupName],[ModifiedDate]FROM [AdventureWorks2014].[HumanResources].[Department]where name=@name

    The stored procedure name is departmentinfo and the input parameter is name. It shows all the information of the department table of the database Adventureworks where the name is equal to the parameter. Once the stored procedure code is done, press update.

    存储过程的名称为departmentinfo,输入参数为name。 它显示名称等于该参数的数据库Adventureworks的部门表的所有信息。 一旦存储过程代码完成,请按更新。

    Figure 15. Stored procedure with parameter图15.带参数的存储过程

  16. In the Previous Database Updates window, press the update database button.

    在“以前的数据库更新”窗口中,按更新数据库按钮。

    Figure 16. Update database图16.更新数据库

  17. You can verify in the SSMS of the Azure VM that the stored procedure was created successfully.

    您可以在Azure VM的SSMS中验证存储过程已成功创建。

    Figure 17. The stored procedure created.图17.创建的存储过程。

  18. To execute the stored procedure, on Visual Studio, right click on the stored procedure and select Execute.

    要执行存储过程,请在Visual Studio上右键单击存储过程,然后选择执行。

    Figure 18. Executing a 图18.执行 stored procedure存储过程

  19. In the value section specify a value. Check the step 8 to verify valid values. The stored procedure receives the Department name and returns the information of the department. In this example, we are inserting the IT name. Press OK.

    在值部分中,指定一个值。 检查步骤8以验证有效值。 存储过程接收部门名称并返回部门信息。 在此示例中,我们将插入IT名称。 按确定。

    Figure 19. Parameters for the stored procedure.图19.存储过程的参数。

  20. As you can see, the stored procedure was executed successfully. You can see the T-SQL code generated and the results of the stored procedure. It is showing the information related to the department name specified as input.

    如您所见,存储过程已成功执行。 您可以看到生成的T-SQL代码和存储过程的结果。 它显示与指定为输入的部门名称有关的信息。

    Figure 20. 图20. The stored procedure execution results存储过程的执行结果

  21. Finally, let’s create an Azure function using Visual Studio. We will use the Employee table that contains the following information:

    最后,让我们使用Visual Studio创建一个Azure函数。 我们将使用Employee表,其中包含以下信息:

    Figure 21. The table that will be used to create the function. 图21. 用于 创建函数 的表格

    The table contains Employees information. We will send the the function the LoginID and we want to receive the age of the employee based on the birthdate. For example, the login Adventure-works\ken0 has 46 years.

    该表包含员工信息。 我们将向该函数发送LoginID,并希望根据出生日期接收员工的年龄。 例如,登录Adventure-works \ ken0有46年。

  22. To create a Functions right click on Functions in Visual Studio.There are several types of functions:

    要创建函数,请在Visual Studio中的“函数”上单击鼠标右键。有几种类型的函数:

    • Inline Functions: They return a table. It is like a parameterized view. We will use this type of functions today.内联函数:它们返回一个表。 它就像一个参数化视图。 我们今天将使用这种类型的功能。
    • Table-valued Function: They also return a table, but they allow a more powerful programming logic that the other functions.表值函数:它们还返回一个表,但是它们允许比其他函数更强大的编程逻辑。
    • Scalar-valued Function: They return a scalar value.

      标量值函数:它们返回标量值。

    Figure 22. The types of functions图22.函数类型

  23. Write the following code to create the function:

    编写以下代码以创建函数:

    
    CREATE FUNCTION [dbo].[returnage]
    (@LoginId nvarchar(26)
    )
    RETURNS TABLE AS RETURN
    (SELECT  DATEDIFF(yy,BirthDate,GETDATE()) as ageFROM [AdventureWorks2014].[HumanResources].[Employee]WHERE LoginId = @LoginId
    )

    The Function name is returnage. It receives de loginId from the Employee table and the functions calculates the age of the employee with using the BirthDate.

    功能名称是退货。 它从Employee表中接收de loginId,并且这些函数使用BirthDate计算雇员的年龄。

  24. Once your code is done, press Update and repeat the step 16.

    完成代码后,请按Update并重复步骤16。

    Figure 23. Updating the function图23.更新功能

  25. To verify that the function was created press the refresh icon. You will be able to see the returnage function.

    要验证该功能已创建,请按刷新图标。 您将能够看到退货功能。

    Figure 24. The Function created图24.创建的函数

  26. If you expand the function, you will be able to see that the loginID is the input parameter and the age the column returned.

    如果展开该功能,您将能够看到loginID是输入参数,并且返回该列的使用期限。

    Figure 25. Input function parameter图25.输入函数参数

  27. To test the function, right click on the function and press Execute.

    要测试该功能,请右键单击该功能,然后按执行。

    Figure 26. Function execution图26.函数执行

  28. Write a LoginId, check the figure 21 for valid values and press OK.

    编写一个LoginId,检查图21中的有效值,然后按OK。

    Figure 27. The function parameter specified for execution图27.指定执行的函数参数

  29. You will be able to see the function execution T-SQL code and the result. The LoginID adventure-works\roberto0 has the age of 41 years.

    您将能够看到函数执行的T-SQL代码和结果。 LoginID adventure-works \ roberto0的年龄为41岁。

    Figure 28. 图28. The function results函数结果

  30. 结论 ( Conclusion )

    Visual Studio is a great and easy to use tool to program. In this article we show how simple is to connect to a VM machine in Azure and create SQL Server stored procedures, functions and to update the information.

    Visual Studio是一款出色且易于使用的编程工具。 在本文中,我们展示了连接到Azure中的VM机器并创建SQL Server存储过程,函数以及更新信息的简单程度。

翻译自: https://www.sqlshack.com/how-to-work-with-visual-studio-and-vm-databases-in-azure/

批量关停azure vm

批量关停azure vm_如何在Azure中使用Visual Studio和VM数据库相关推荐

  1. java visual linux,如何在 Linux 中安装 Visual Studio Code

    你们好,今天咱们一块儿来学习如何在 Linux 发行版中安装 Visual Studio Code.Visual Studio Code 是基于 Electron 优化代码后的编辑器,后者是基于 Ch ...

  2. 在linux安装编译vscode,Linux中安装 Visual Studio Code 详解

    一起来学习如何在 Linux 发行版中安装 Visual Studio Code.Visual Studio Code 是基于 Electron 优化代码后的编辑器,后者是基于 Chromium 的一 ...

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

    批量关停azure vm 介绍 ( Introduction ) In this new article, we will create a SQL Server Report using SQL S ...

  4. azure blob_如何在Azure Blob存储中恢复意外删除

    azure blob This article explains one of the important data protection features in Azure Blob Storage ...

  5. 在Ubuntu中安装Visual Studio Code

    微软令人意外地发布了Visual Studio Code,并支持主要的桌面平台,当然包括linux.如果你是一名需要在Ubuntu工作的web开发人员,你可以非常轻松的安装Visual Studio ...

  6. 马云、马化腾任职清华;微软将数据保存在玻璃中;Visual Studio Online 上线 | 极客头条...

    整理 | 屠敏 快来收听极客头条音频版吧,智能播报由标贝科技提供技术支持. 「CSDN 极客头条」,是从 CSDN 网站延伸至官方微信公众号的特别栏目,专注于一天业界事报道.风里雨里,我们将每天为朋友 ...

  7. 11月5日科技资讯|马云、马化腾任职清华;微软将数据保存在玻璃中;Visual Studio Online 上线 | 极客头条

    「CSDN 极客头条」,是从 CSDN 网站延伸至官方微信公众号的特别栏目,专注于一天业界事报道.风里雨里,我们将每天为朋友们,播报最新鲜有料的新闻资讯,让所有技术人,时刻紧跟业界潮流. 整理 | 屠 ...

  8. 在fluent中引入visual studio

    前言: 建议版本.一些勾选项完全按照本教程中的来,我之前失败了很多次/(ㄒoㄒ)/~~ 安装路径中不可出现中文!!以及一些符号(我的建议是路径全英文小写,保险!) 可以装在D盘!!(之前有看别的博主说 ...

  9. 在 Mac中使用visual studio code 调试 C,C++代码

    在 Mac上有时候需要编写一些 C 或者 C++的代码,如果使用 xcode,有时候就显得很笨重,而且运行起来很不方便.而微软提供了一个跨平台的编辑器 Visual studio code ,这个编辑 ...

最新文章

  1. ubuntu下安装2个mysql_Linux 同一系统安装两个MySQL
  2. 1.8正版生存服务器,我的世界1.8-1.16.5 qqof 生存服务器
  3. JDK提供的原子类原理与使用
  4. 福州大学软件1715|W班-助教卞倩虹个人简介
  5. 字符串暴力匹配算法+思路分析
  6. 【java】LongAdder源码分析原理分析
  7. linux自动分区shell,SHELL脚本实现分区
  8. python库skimage 常值轮廓寻找并标记
  9. win7计算机无法连接投影仪,Win7电脑如何连接投影仪?投影仪连接电脑用什么线连接?...
  10. 《经济机器是怎样运行的》笔记(一)
  11. 云平台与操作系统两种架构的分析
  12. Adobe PS常用快捷键
  13. 如何防止亚马逊账号被关联?
  14. 简单实现你想数字电脑猜的小游戏
  15. 计算机的rom是内存的意思,电脑ram和rom是什么意思 电脑内存条是rom还是ram
  16. 《RHCE考试必看》
  17. 记录自学编程的博客 -2019年
  18. 阿里云ECS通用型g7云服务器支持vTPM第三代神龙架构性能评测
  19. 括号匹配算法问题 JS
  20. Wired特写: 网络让她陷入「匿名虐待」的世界,这是一场关于数据和不信任的无休止暴力

热门文章

  1. od找数据 遇到dll_OriginPro:最近比较烦,被360盯上了【数据绘图】
  2. c++ 中文 base64加密_这次有点骚了,破解安卓某 APP 低层加密
  3. python中texttable库显示实时数据_python显示数据库数据
  4. python字符串函数的find方法_python字符串的方法与操作大全
  5. Grid使用 ComboBox Binding DateTime Format WPF
  6. 更改TFS项目中的SharePoint网站端口
  7. 杭电OJ 敌兵布阵 树状数组
  8. JS:ES6-12 模块化
  9. 零基础带你学习MySQL—foreign key 外键(二十六)
  10. 解决VScode安装Babel转码器报错:无法将“cnpm“项识别为cmdlet\函数、脚本文件或可运行程序的名称的问题