Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Runbook用于启动/停止虚拟机_Azure_Powershell_Automation_Azure Automation_Azure Runbook - Fatal编程技术网

Azure Runbook用于启动/停止虚拟机

Azure Runbook用于启动/停止虚拟机,azure,powershell,automation,azure-automation,azure-runbook,Azure,Powershell,Automation,Azure Automation,Azure Runbook,因此,我有一组分布在不同资源组中的虚拟机,我想让它们根据特定时间关闭/启动。我希望尽可能简单地管理它,并试图找到一种使用标记和运行手册来实现这一点的方法。问题是,我希望他们能够根据他们的资源组在不同的时间启动/停止。到目前为止,我已经为所有具有相同标记名的VM创建了标记,标记值是资源组名。我怎样才能使我要做的事情尽可能简单?调用其他运行手册的运行手册是一个好的解决方案吗? 有一个关于启动/停止虚拟机的教程: 或者,您可以自己在自动化中编写自己的脚本。想想逻辑。以下是一些您可以参考的片段。

因此,我有一组分布在不同资源组中的虚拟机,我想让它们根据特定时间关闭/启动。我希望尽可能简单地管理它,并试图找到一种使用标记和运行手册来实现这一点的方法。问题是,我希望他们能够根据他们的资源组在不同的时间启动/停止。到目前为止,我已经为所有具有相同
标记名
的VM创建了标记,
标记值
是资源组名。我怎样才能使我要做的事情尽可能简单?调用其他运行手册的运行手册是一个好的解决方案吗?

  • 有一个关于启动/停止虚拟机的教程:

  • 或者,您可以自己在自动化中编写自己的脚本。想想逻辑。以下是一些您可以参考的片段。有关如何使用PowerShell命令行的详细信息,最好参考Microsoft文档
1.通过
$allvms=Get AzureVM
获取订阅中的所有虚拟机

2.通过以下方式启动特定资源组中的虚拟机:

foreach($thisvm in $allvms)
{
Start-AzureRmVM -ResourceGroupName "AzureRG2" -Name "$thisvm"
}
foreach($thisvm in $allvms)
{
Stop-AzureRmVM -ResourceGroupName "AzureRG1" -Name "$thisvm"
}
3.通过以下方式停止特定资源组中的VM

foreach($thisvm in $allvms)
{
Start-AzureRmVM -ResourceGroupName "AzureRG2" -Name "$thisvm"
}
foreach($thisvm in $allvms)
{
Stop-AzureRmVM -ResourceGroupName "AzureRG1" -Name "$thisvm"
}
4.链接要启动或关闭虚拟机的不同计划

5.不要忘记在azure automation中安装模块