Microsoft Azure Essentials: Azure Automation

Page 88

Following a time-intensive or resource expensive activity—to save Azure costs.

Within any runbook that will exceed the “Fair Share” limit.

Before any activity that has a large chance that it could lead to failure and suspension of a workflow. For instance, any code that calls an external system can be prone to failures.

Here are some locations in runbooks in which checkpoints should not be used: 

After code that the workflow should do again if it is suspended and resumed.

After work that is idempotent.

After inexpensive work that is less costly to repeat than creating a checkpoint.

InlineScript blocks cannot use checkpoints because the code in InlineScript is run as Windows PowerShell script, not a Windows PowerShell workflow.

For variables that use large amounts of data but don’t need to be saved, copy them to $null immediately before the checkpoint. Sending the result of an operation to $null simply causes it to be discarded. This way that data will not be checkpointed, reducing data transfer for a checkpoint.

You can force the creation of a checkpoint right after an activity finishes that you call by including the PSPersist common parameter for instance, Restart-VM –PSPersist $True.

You can also include $PSPersistPreference = $True at the start of a module to cause a checkpoint to be taken after each activity that follows the preference statement. If you set this preference at the start of the runbook, a checkpoint will be made after each activity in the runbook.

You can turn off the automatic checkpointing by including the statement $PSPersistPreference = $False (which is the runbook default), after which activities will run without automatic checkpoints.

Persisting after every activity might not always be good for runbook performance. At a checkpoint the workflow state is persisted to the database. At times, checkpointing might not match the business logic you’d want to use if a certain step fails. Sometimes you’ll want to repeat multiple steps if a step fails, which checkpointing after every activity would not allow.

Retrieve credentials again from the Automation asset store after a checkpoint

Avoid using checkpoints that require that a large amount of data be persisted to a database

87


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.