首页 技术 正文
技术 2022年11月16日
0 收藏 439 点赞 2,557 浏览 1790 个字

  《Windows Azure Platform 系列文章目录

  通过Azure Automation(自动化),开发人员可以自动完成通常要在云环境中执行的手动、长时间进行、易出错且重复性高的任务。你可以使用 Runbook 来创建、监视、管理和部署 Azure 环境中的资源。所谓的 Runbook,基本上就是指 Windows PowerShell 工作流。

  Azure Automation概念上类似Windows Service,SQL Server Job。

  Azure Automation可以无人值守,自动化运行。

  Azure Automation有三个非常重要的概念:

  1.Automation,一组业务逻辑的集合。包含多个RunBook和多个Schedule。

  2.RunBook,运行业务逻辑的主题

  3.Schedule,调度RunBook的计划任务。一个Schedule可以调度多个RunBook

  举个例子,假设我们每天早上9点上班之前把一个订阅下所有的虚拟机开启,然后在下午6点下班以后把所有的虚拟机关闭,这样是非常节省成本的。

  以前我们需要通过单独某一台Azure虚拟机,定期执行PowerShell命令,因为虚拟机按照小时收费,成本会非常高,非常不划算。

  另外单独的Azure虚拟机会产生单点故障,从可靠性角度来说,也是无法保障的。

  通过使用Azure Automation,可以设置自动化的工作流,定期执行负载的业务逻辑。

  Azure Automation功能非常强大。微软Azure Automation团队提供了Runbook实例代码,读者可以浏览http://go.microsoft.com/fwlink/p/?linkid=393029&clcid=0x409,进行参考。

  最后,笔者演示一个简单的Azure Automation Hello World,使用国内由世纪互联运维的Azure China

  1.首先我们登陆管理界面,地址https://manage.windowsazure.cn

  2.选择Automation,点击Create an automation account。如下图:

  Azure Automation (1) 入门

  

  2.输入Automation的名字,如下图:

  Azure Automation (1) 入门

  

  3.在Automation栏目,选择我们之前创建的LeiAutomation。如下图:

  Azure Automation (1) 入门

  4.页面跳转,我们点击RUNBOOKS,然后点击IMPORT,如下图:

  Azure Automation (1) 入门

  5.打开浏览器浏览https://gallery.technet.microsoft.com/scriptcenter/The-Hello-World-of-Windows-81b69574

  下载相应的PS1脚本并通过上图导入到Azure Runbook。如下图:

  Azure Automation (1) 入门

  6.导入成功后,我们就可以查看到该RunBook。如下图:

  Azure Automation (1) 入门

  

  7.我们点击上图中的Write-HelloWorld,页面跳转,然后我们点击Author。如下图:

  Azure Automation (1) 入门

  8.可以看到这个RunBook的业务很简单,就是输出Hello World。具体代码如下:

workflow Write-HelloWorld {
param ( # Optional parameter of type string.
# If you do not enter anything, the default value of Name
# will be World
[parameter(Mandatory=$false)]
[String]$Name = "World"
) Write-Output "Hello $Name"}

  9.我们可以通过点击TEST来进行调试。如下图:

  Azure Automation (1) 入门

  

  10.调试成功后,我们就可以点击PUBLISH进行发布。如下图:

  Azure Automation (1) 入门

  11.发布成功后,我们可以在PUBLISHED里面看到发布的RUNBOOK项目,如下图:

  Azure Automation (1) 入门

  

  12.我们点击PUBLISH里面的Start按钮,可以执行该RUNBOOK。如下图:

  Azure Automation (1) 入门

  

  13.执行成功后,我们可以在Jobs里,查看到之前执行的Job。如下图:

  Azure Automation (1) 入门

  14.我们点击上图的JOB CREATED,就可以查看到执行的具体情况。图略。

  15.如果我们点击SCHEDULE,就可以定期,比如每小时,每天执行这个RUNBOOK。如下图:

  Azure Automation (1) 入门

  

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,299