Skip to content

Files

Latest commit

 

History

History
104 lines (79 loc) · 5.02 KB

automation-watchers-tutorial.md

File metadata and controls

104 lines (79 loc) · 5.02 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.devlang ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author
Create a watcher task in the Azure Automation account | Microsoft Docs
Learn how to create a watcher task in the Azure Automation account to watch for new files created in a folder.
automation
eamonoreilly
0dd95270-761f-448e-af48-c8b1e82cd821
automation
na
article
na
infrastructure-services
01/15/2017
eamono

Azure Automation watcher tasks enable you to respond to events happening in your local datacenter

In this tutorial, you learn how to create a new watcher task to:

[!div class="checklist"]

  • Create a watcher runbook that looks for new files in a directory.
  • Create an Automation variable to keep the last time a file was processed by the watcher.
  • Create an action runbook that is called when the watcher runbook finds a new file.
  • Create a watcher task that selects the watcher runbook and action runbook.
  • Trigger a watcher by adding a new file to a directory.
  • Inspect the output from the action runbook that shows information on the new file.

Prerequisites

To complete this tutorial, the following are required.

Create a Watcher runbook that looks for new files

  1. Open the Automation account, and click on the Runbooks page.
  2. Click on the “Browse gallery” button. Runbook list from UI
  3. Search for “Watch-NewFile” and import the runbook into the Automation account. Publish runbook from UI
  4. Click on “Edit” to view the Runbook source and click on the “Publish” button.

Create an Automation variable to keep the last time a file was processed by the watcher

  1. Open up the variables page under SHARED RESOURCES and click on “Add variable” List variables from UI
  2. Enter “Watch-NewFileTimestamp” for the name
  3. Select Type as DateTime and then click on the “Create” button. Create watermark variable from UI

Create an action runbook that is called when the watcher runbook finds a new file

  1. Click on the Runbooks page under the “PROCESS AUTOMATION” category.
  2. Click on the “Browse gallery” button.
  3. Search for “Process-NewFile” and import the runbook into the Automation account.
  4. Click on “Edit” to view the Runbook source and click on the “Publish” button. Process watcher from UI

Create a watcher task that selects the watcher runbook and action runbook

  1. Open the Watcher tasks page and click on “Add a watcher task” button. Watcher list from UI
  2. Enter “WatchMyFolder” as the name.
  3. Select “Configure watcher” and select the “Watch-NewFile” runbook. Configure watcher from UI
  4. Enter the following values for parameters:
    • FOLDERPATH. A folder on the hybrid worker where new files get created
    • EXTENSION. Leave blank to process all file extensions.
    • RECURSE. Leave the default.
    • RUN SETTINGS. Pick the hybrid worker.
  5. Click OK, and then Select to return to the watcher page.
  6. Select “Configure action” and select “Process-NewFile” runbook. Configure watcher action from UI
  7. Enter the following values for parameters:
    • EVENTDATA. Leave blank. Data is passed in from the watcher runbook.
    • Run Settings. Leave as Azure as this runbook runs in the Automation service.
  8. Click OK, and then Select to return to the watcher page.
  9. Click OK to create the watcher task.

Trigger a watcher by adding a new file to a directory

  1. Remote into the hybrid worker
  2. Add a new text file to the folder that is being monitored by the watcher task.

Inspect the output from the action runbook that shows information on the new file

  1. Click on the watcher task for “WatchMyFolder”
  2. Click on the “View watcher streams” to see that the watcher found the new file and started the action runbook.
  3. Click on the “View watcher action jobs” to see the action runbook job. Watcher action jobs from UI

Next steps:

For more information, see My first PowerShell runbook.