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 |
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.
To complete this tutorial, the following are required.
- Azure subscription. If you don't have one yet, you can activate your MSDN subscriber benefits or sign up for a free account.
- Automation account to hold the watcher and action runbooks and the Watcher Task.
- A hybrid runbook worker where the watcher task runs.
- Open the Automation account, and click on the Runbooks page.
- Click on the “Browse gallery” button.
- Search for “Watch-NewFile” and import the runbook into the Automation account.
- Click on “Edit” to view the Runbook source and click on the “Publish” button.
- Open up the variables page under SHARED RESOURCES and click on “Add variable”
- Enter “Watch-NewFileTimestamp” for the name
- Select Type as DateTime and then click on the “Create” button.
- Click on the Runbooks page under the “PROCESS AUTOMATION” category.
- Click on the “Browse gallery” button.
- Search for “Process-NewFile” and import the runbook into the Automation account.
- Click on “Edit” to view the Runbook source and click on the “Publish” button.
- Open the Watcher tasks page and click on “Add a watcher task” button.
- Enter “WatchMyFolder” as the name.
- Select “Configure watcher” and select the “Watch-NewFile” runbook.
- 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.
- Click OK, and then Select to return to the watcher page.
- Select “Configure action” and select “Process-NewFile” runbook.
- 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.
- Click OK, and then Select to return to the watcher page.
- Click OK to create the watcher task.
- Remote into the hybrid worker
- Add a new text file to the folder that is being monitored by the watcher task.
- Click on the watcher task for “WatchMyFolder”
- Click on the “View watcher streams” to see that the watcher found the new file and started the action runbook.
- Click on the “View watcher action jobs” to see the action runbook job.
For more information, see My first PowerShell runbook.