本文说明的是使用Checkpoint-workflow的一种场景(当然还有其他场景需要Checkpoint-workflow)。

起因:Windows Azure对Automation账户中的Runbook运行时长限制了30minutes。

机制:就是如果你的脚本在30minutes内没有运行完成, 那么执行脚本的Worker会暂定你的脚本,去处理其他账户的任务。

问题:当下一个Worker再来执行您的脚本时,是从最近一次的Checkpoint开始的。如果你未能在脚本执行过程中设置Checkpoint而你的脚本执行时长又大于30minutes,那边你的脚本每次都会从头开始。

这样,永无止境的执行下去,直到系统检测到这种情况并给你抛出异常。

The job cannot continue running because it was repeatedly evicted from the same checkpoint. Please make sure your Runbook does not perform lengthy operations without persisting its state.

Checkpoint Workflow

<Activity1>
Checkpoint-Workflow
<Activity2>
<Error>
<Activity3>

注意的是Checkpoint-Workflow不能放在Inlinescript当中。

关于Checkpoint,参考 http://azure.microsoft.com/en-us/blog/azure-automation-reliable-fault-tolerant-runbook-execution-using-checkpoints/

some good points about checkpoint-workflow from Runbook concepts(https://technet.microsoft.com/en-us/library/Dn469257.aspx)

You can set a checkpoint in a workflow with the Checkpoint-Workflow activity. When you include this activity in a runbook, a checkpoint is immediately taken. If the runbook is suspended by an error, when the job is resumed, it will resume from the point of the last checkpoint set.

Some good points about InlineScript 

The InlineScript activity runs a block of commands in a separate, non-workflow session and returns its output to the workflow. While commands in a workflow are sent to Windows Workflow Foundation for processing, commands in an InlineScript block are processed by Windows PowerShell. The activity uses the standard workflow common parameters including PSComputerName and PSCredential which allow you to specify that the code block be run on another computer or using alternate credentials.

While InlineScript activities may be critical in certain runbooks, they should only be used when necessary for the following reasons:

  • You cannot use checkpoints from within an InlineScript block. If a failure occurs within the block, it must be resumed from the beginning.

  • InlineScript affects scalability of the runbook since it holds the Windows PowerShell session for the entire length of the InlineScript block.

  • Activities such as Get-AutomationVariable and Get-AutomationPSCredential are not available in an InlineScript block.

you do need to use an InlineScript, you should minimize its scope. For example, if your runbook iterates over a collection while applying the same operation to each item, the loop should occur outside of the InlineScript. This will provide the following advantages:

  • You can checkpoint the workflow after each iteration. If the job is suspended or interrupted and resumed, the loop will be able to resume.

  • You can use ForEach –Parallel to handle collection items concurrently.

Keep the following recommendations in mind if you do use an InlineScript in your runbook:

  • You can pass values into the script though with the $Using scope modifier. For example, a variable called $abc that has been set outside of the InlineScript would become $using:abc inside an InlineScript.

  • To return output from an InlineScript, assign the output to a variable and output any data to be returned to the output stream. The following example assigns the string “hi” to a variable called $output.

     
    $output = InlineScript { Write-Output "hi" }
    
  • Avoid defining workflows within InlineScript scope. Even though some workflows may appear to operate correctly, this is not a tested scenario. As a result, you may encounter confusing error messages or unexpected behavior.

在Runbook中添加Checkpoint-workflow的更多相关文章

  1. odoo 在原有工作流中添加审批流

    odoo 在原有工作流中添加审批流 步骤: 1.加入所需的工作流节点以及相连的线(即所添加的审批流),代码如下: <?xml version="1.0" encoding=& ...

  2. 在jekyll模板博客中添加网易云模块

    最近使用GitHub Pages + Jekyll 搭建了个人博客,作为一名重度音乐患者,博客里面可以不配图,但是不能不配音乐啊. 遂在博客里面引入了网易云模块,这里要感谢网易云的分享机制,对开发者非 ...

  3. 在Linux(Luna)下向Launch启动器中添加图标

    记录下在Luna下向Launch中添加图标的步骤,以供以后参考,这里我以加入eclipse图标为例: 首先,我们来创建一个desktop文件(Luna中到启动器Launch可以看作是Ubuntu中到桌 ...

  4. 用Retrofit发送请求中添加身份验证

    用Retrofit发送请求中添加身份验证====================在安卓应用开发中, retrofit可以极大的方便发送http网络请求,不管是GET, POST, 还是PUT, DEL ...

  5. 在html中添加script脚本的方法和注意事项

    在html中添加script脚本有两种方法,直接将javascript代码添加到html中与添加外部js文件,这两种方法都比较常用,大家可以根据自己需要自由选择 在html中添加<script& ...

  6. MVC学习随笔----如何在页面中添加JS和CSS文件

    http://blog.csdn.net/xxjoy_777/article/details/39050011 1.如何在页面中添加Js和CSS文件. 我们只需要在模板页中添加JS和CSS文件,然后子 ...

  7. 怎样在Windows资源管理器中添加右键菜单以及修改右键菜单顺序

    有时,我们需要在Windows资源管理器的右键菜单中添加一些项,以方便使用某些功能或程序. 比如我的电脑上有一个免安装版的Notepad++,我想在所有文件的右键菜单中添加一项用Notepad++打开 ...

  8. 在WebStorm环境中给nodejs项目中添加packages

    照前文 http://www.cnblogs.com/wtang/articles/4133820.html  给电脑设置了WebStorm的IDE的nodejs开发环境.新建了个express的网站 ...

  9. dotnet webapi 中添加Swagger文档

    首先添加"SwaggerGenerator": "1.1.0","SwaggerUi": "1.1.0" 需要注意的是这 ...

随机推荐

  1. backbonejs中的模型篇(一)

    一:模型及属性 模型是MVC应用的基石,它负责存放应用所需的数据,对数据的验证,执行访问控制,以及实现应用所需的特定业务逻辑. backbone通过扩展Backbone.Model对象来定义一个模型. ...

  2. Collecting Bugs(POJ 2096)

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 3064   Accepted: 1505 ...

  3. Java:Exception

    异常: 就是程序在运行时出现不正常的情况. 异常的由来:问题也是现实生活中一个具体的事物,也可以通过java的类的形式进行描述,并封装成对象.其实就是Java对不正常情况进行描述后的对象的体现. 两种 ...

  4. windows下phpstorm的快捷键

    ctrl+shift+n查找文件 ctrl+shift+f 在一个目录里查找一段代码(ctrl+f的升级版) ctr+shift+r 在一个目录里查找一段代码并替换(ctrl+r的升级版) CTRL+ ...

  5. 文本信息“welcome to java programming!”

    import javax.swing.JOptionPanepublic class welcome {public static void main(string[] arg){JOptionPan ...

  6. model.addAttribute("student",student)——渲染

    往前台视图传参数,(将在处理器传入的模型数据在视图jsp中展示出来,即为渲染) 按照spring一般的编码习惯,model 应该是contrller里面的Map结构吧.Map里面添加key=" ...

  7. 【C语言学习】-04 一维数组、字符数组

    一维数组.数组排序.字符数

  8. [mr440] 崎岖的山区

    极类似动归的广搜?反正各种算法傻傻分不清…写之前叹了一句,好久不写广搜了啊!呵呵真的写了好久,大约一个钟头? f[i,j,0]表示到点(i,j)且最后一步为下降的最少步数,f[i,j,1]就是上升.莫 ...

  9. eclipse 提交作业到JobTracker Hadoop的数据类型要求必须实现Writable接口

    问:在eclipse中的写的代码如何提交作业到JobTracker中的哪?答:(1)在eclipse中调用的job.waitForCompletion(true)实际上执行如下方法 connect() ...

  10. 记录一些容易忘记的属性 -- NSTimer

    使定时器停止的方法: 1. //将定时器的启动时间设置为很久以后的将来,到这个时间,定时器才会开始工作            [_timer setFireDate:[NSDate distantFu ...