更多内容,请关注公众号:

Azure 上通过Automation 实现定时开关虚拟机

 

Azure Automation 可以提供一些自动化的功能,比如我们可以指定在每天早上6点开启虚拟机,每天晚上8点关闭虚拟机。
同时还提供一些基于监控参数的自动化配置。今天的主要内容是介绍通过Automation 实现定时对虚拟机进行开机和关机操作。

 实战演练视频:

https://v.qq.com/x/page/r3023ijwt3e.html

Azure对不同状态下的虚拟机计费情况:

Azure 上通过Automation 实现定时开关虚拟机

 

workflow startVM
{
    $Cred = Get-AutomationPSCredential -Name "test-cred"; 
    Add-AzureRmAccount -Credential $Cred -EnvironmentName AzureChinaCloud;
    Select-AzureRmSubscription -SubscriptionId "xxxx-xxxx-xxxx";
    Start-AzureRmVM -ResourceGroupName "seanyutest" -Name "testvm"
}


workflow startVM
{
    $Cred = Get-AutomationPSCredential -Name "test-cred"; 
    Add-AzureRmAccount -Credential $Cred -EnvironmentName AzureChinaCloud;
    Select-AzureRmSubscription -SubscriptionId "xxxx-xxxx-xxxx";
    Stop-AzureRmVM -ResourceGroupName "seanyutest" -Name "testvm" -Force
}

  

注意关机时应该增加参数-Force,因为在powershell中执行关机时,会有交互内容,需从键盘输入YES才会执行关机操作,当我们通过Automation执行关机时,则应该强制关机。

 

目前支持的Runbook有如下几种类型:

Azure 上通过Automation 实现定时开关虚拟机

 

 可以将有关组织如何交付和维护工作负荷的知识传输到系统中;主要可以实现以下内容:

集成到 Jenkins 等开发工具中。

配置 VM - 使用基础结构和应用程序所需的配置评估和配置 Windows 和 Linux 计算机。

监视 - 确定计算机上那些导致问题的更改,进行相应的补救,或者将其升级到管理系统。

设置来宾内要求。

恢复未使用的资源。

 

定价:

Azure 上通过Automation 实现定时开关虚拟机

 

相关文章:

  • 2021-12-06
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-06-06
  • 2022-01-13
  • 2021-10-08
猜你喜欢
  • 2022-02-03
  • 2021-11-13
  • 2021-07-27
  • 2021-07-06
  • 2021-12-24
相关资源
相似解决方案