Tutorial: Use playbooks with automation rules in Azure Sentinel
This tutorial shows you how to use playbooks together with automation rules to automate your incident response and remediate security threats detected by Azure Sentinel. When you complete this tutorial you will be able to:
- Create an automation rule
- Create a playbook
- Add actions to a playbook
- Attach a playbook to an automation rule or an analytics rule to automate threat response
What are automation rules and playbooks?
Automation rules help you triage incidents in Azure Sentinel. You can use them to automatically assign incidents to the right personnel, close noisy incidents or known false positives, change their severity, and add tags. They are also the mechanism by which you can run playbooks in response to incidents.
Playbooks are collections of procedures that can be run from Azure Sentinel in response to an alert or incident. A playbook can help automate and orchestrate your response, and can be set to run automatically when specific alerts or incidents are generated, by being attached to an analytics rule or an automation rule, respectively. It can also be run manually on-demand.
Playbooks in Azure Sentinel are based on workflows built in Azure Logic Apps, which means that you get all the power, customizability, and built-in templates of Logic Apps. Each playbook is created for the specific subscription to which it belongs, but the Playbooks display shows you all the playbooks available across any selected subscriptions.
Because playbooks make use of Azure Logic Apps, additional charges may apply. Visit the Azure Logic Apps pricing page for more details.
For example, if you want to stop potentially compromised users from moving around your network and stealing information, you can create an automated, multifaceted response to incidents generated by rules that detect compromised users. You start by creating a playbook that takes the following actions:
When the playbook is called by an automation rule passing it an incident, the playbook opens a ticket in ServiceNow or any other IT ticketing system.
It also sends all the information in the incident in an email message to your senior network admin and security admin. The email message will include Block and Ignore user option buttons.
The playbook waits until a response is received from the admins, then continues with its next steps.
If the admins choose Block, it sends a command to Azure AD to disable the user, and one to the firewall to block the IP address.
If the admins choose Ignore, the playbook closes the incident in Azure Sentinel, and the ticket in ServiceNow.
In order to trigger the playbook, you'll then create an automation rule that runs when these incidents are generated. That rule will take these steps:
The rule changes the incident status to Active.
It assigns the incident to the analyst tasked with managing this type of incident.
It adds the "compromised user" tag.
Finally, it calls the playbook you just created. (Special permissions are required for this step.)
Playbooks can be run automatically in response to incidents, by creating automation rules that call the playbooks as actions, as in the example above. They can also be run automatically in response to alerts, by telling the analytics rule to automatically run one or more playbooks when the alert is generated.
You can also choose to run a playbook manually on-demand, as a response to a selected alert.
Create a playbook
Follow these steps to create a new playbook in Azure Sentinel:
Prepare the playbook and Logic App
From the Azure Sentinel navigation menu, select Automation.
On the top menu, select Create and Add new playbook.
A new browser tab will open and take you to the Create a logic app wizard.
Enter your Subscription and Resource group, and give your playbook a name under Logic app name.
For Region, select the Azure region where your Logic App information is to be stored.
If you want to monitor this playbook's activity for diagnostic purposes, mark the Enable log analytics check box, and enter your Log Analytics workspace name.
If you want to apply tags to your playbook, click Next : Tags > (not connected to tags applied by automation rules. Learn more about tags). Otherwise, click Review + Create. Confirm the details you provided, and click Create.
While your playbook is being created and deployed (this will take a few minutes), you will be taken to a screen called Microsoft.EmptyWorkflow. When the "Your deployment is complete" message appears, click Go to resource.
You will be taken to your new playbook's Logic Apps Designer, where you can start designing the workflow. You'll see a screen with a short introductory video and some commonly used Logic App triggers and templates. Learn more about creating a playbook with Logic Apps.
Select the Blank Logic App template.
Choose the trigger
Every playbook must start with a trigger. The trigger defines the action that will start the playbook and the schema that the playbook will expect to receive.
In the search bar, look for Azure Sentinel. Select Azure Sentinel when it appears in the results.
In the resulting Triggers tab, you will see the two triggers offered by Azure Sentinel:
- When a response to an Azure Sentinel Alert is triggered
- When Azure Sentinel incident creation rule was triggered
Choose the trigger that matches the type of playbook you are creating.
Now you can define what happens when you call the playbook. You can add actions, logical conditions, loops, or switch case conditions, all by selecting New step. This selection opens a new frame in the designer, where you can choose a system or an application to interact with or a condition to set. Enter the name of the system or application in the search bar at the top of the frame, and then choose from the available results.
In every one of these steps, clicking on any field displays a panel with two menus: Dynamic content and Expression. From the Dynamic content menu, you can add references to the attributes of the alert or incident that was passed to the playbook, including the values and attributes of all the entities involved. From the Expression menu, you can choose from a large library of functions to add additional logic to your steps.
This screenshot shows the actions and conditions you would add in creating the playbook described in the example at the beginning of this document. The only difference is that in the playbook shown here, you are using the alert trigger instead of the incident trigger. This means that you'll call this playbook from an analytics rule directly, not from an automation rule. Both ways of calling a playbook will be described below.
Automate threat responses
You've created your playbook and defined the trigger, set the conditions, and prescribed the actions that it will take and the outputs it will produce. Now you need to determine the criteria under which it will run and set up the automation mechanism that will run it when those criteria are met.
Respond to incidents
You use a playbook to respond to an incident by creating an automation rule that will run when the incident is generated, and in turn it will call the playbook.
To create an automation rule:
From the Automation blade in the Azure Sentinel navigation menu, select Create from the top menu and then Add new rule.
The Create new automation rule panel opens. Enter a name for your rule.
If you want the automation rule to take effect only on certain analytics rules, specify which ones by modifying the If Analytics rule name condition.
Add any other conditions you want this automation rule's activation to depend on. Click Add condition and choose conditions from the drop-down list. The list of conditions is populated by alert detail and entity identifier fields.
Choose the actions you want this automation rule to take. Available actions include Assign owner, Change status, Change severity, Add tags, and Run playbook. You can add as many actions as you like.
If you add a Run playbook action, you will be prompted to choose from the drop-down list of available playbooks. Only playbooks that start with the incident trigger can be run from automation rules, so only they will appear in the list.
Azure Sentinel must be granted explicit permissions in order to run playbooks from automation rules. If a playbook appears "grayed out" in the drop-down list, it means Sentinel does not have permission to that playbook's resource group. Click the Manage playbook permissions link to assign permissions. In the Manage permissions panel that opens up, mark the check boxes of the resource groups containing the playbooks you want to run, and click Apply.
- You yourself must have owner permissions on any resource group to which you want to grant Azure Sentinel permissions, and you must have the Logic App Contributor role on any resource group containing playbooks you want to run.
- In a multi-tenant deployment, if the playbook you want to run is in a different tenant, you must grant Azure Sentinel permission to run the playbook in the playbook's tenant.
- From the Azure Sentinel navigation menu in the playbooks' tenant, select Settings.
- In the Settings blade, select the Settings tab, then the Playbook permissions expander.
- Click the Configure permissions button to open the Manage permissions panel mentioned above, and continue as described there.
Set an expiration date for your automation rule if you want it to have one.
Enter a number under Order to determine where in the sequence of automation rules this rule will run.
Click Apply. You're done!
Discover other ways to create automation rules.
Respond to alerts
You use a playbook to respond to an alert by creating an analytics rule, or editing an existing one, that runs when the alert is generated, and selecting your playbook as an automated response in the analytics rule wizard.
From the Analytics blade in the Azure Sentinel navigation menu, select the analytics rule for which you want to automate the response, and click Edit in the details pane.
In the Analytics rule wizard - Edit existing rule page, select the Automated response tab.
Choose your playbook from the drop-down list. You can choose more than one playbook, but only playbooks using the alert trigger will be available.
In the Review and create tab, select Save.
Run a playbook on demand
You can also run a playbook on demand.
Only playbooks using the alert trigger can be run on-demand.
To run a playbook on-demand:
In the Incidents page, select an incident and click on View full details.
In the Alerts tab, click on the alert you want to run the playbook on, and scroll all the way to the right and click View playbooks and select a playbook to run from the list of available playbooks on the subscription.
In this tutorial, you learned how to use playbooks and automation rules in Azure Sentinel to respond to threats.
- Learn how to proactively hunt for threats using Azure Sentinel.