简体   繁体   English

启动和停止Azure虚拟机

[英]Start and Stop Azure Virtual Machine

I need to start / stop a Azure virtual machine, but I don't know how I can do this. 我需要启动/停止Azure虚拟机,但是我不知道该怎么做。 I don't know anything about Azure or Azure scripts. 我对Azure或Azure脚本一无所知。

You have several options. 您有几种选择。

The first one is by using the Azure Portal. 第一个是使用Azure门户。 Click on your VM and at the bottom you should see a button to stop the virtual machine. 单击您的VM,在底部,您应该看到一个按钮以停止虚拟机。 Starting it again works the same way. 重新启动它的方法相同。

The second option is to use PowerShell. 第二个选项是使用PowerShell。 John McCabe has posted a simple script on his blog to do this. John McCabe在他的博客上发布了一个简单的脚本来执行此操作。 The most important functions are Start-AzureVM and Stop-AzureVM . 最重要的功能是Start-AzureVMStop-AzureVM

If you want to automate this from a developer perspective (which needs a little bit more work than the PowerShell solution) is by using the Azure Management Libraries. 如果要从开发人员角度自动执行此操作(比PowerShell解决方案需要更多的工作),请使用Azure管理库。 Brady Gaster wrote a great post about it. 布雷迪·加斯特(Brady Gaster)撰写了一篇很棒的文章

The fourth option is to use Microsoft Azure Automation . 第四个选项是使用Microsoft Azure自动化 There you create runbooks for common tasks. 在此处,您可以为常见任务创建运行手册。 In the samples are scripts already included which can start and stop a VM. 在示例中,已经包含了可以启动和停止VM的脚本。

within the Azure portal (I would recommend using the new portal), go into the VM you need, on the dashboard you will see a Stop and Start button, or you can choose to Restart the VM. 在Azure门户(我建议使用新门户)中,进入所需的VM,在仪表板上,您将看到“停止并启动”按钮,或者您可以选择重新启动VM。 Hope this helps. 希望这可以帮助。

You can also create a Timer-triggered Azure Function to start/stop your VM. 您还可以创建计时器触发的Azure函数来启动/停止您的VM。 I've provided the steps here: 我在这里提供了步骤:

Azure Function role like permissions to Stop Azure Virtual Machines Azure Function角色,例如停止Azure虚拟机的权限

Instead of creating HTTP-triggered Functions, just use Timer-triggered functions instead and edit the PowerShell script content to hardcode the vmname and resourcegroup. 与其创建HTTP触发的函数,不如使用计时器触发的函数,然后编辑PowerShell脚本内容以对vmname和资源组进行硬编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM