Tutorial: Schedule a recurring experiment with Azure Chaos Studio

Azure Chaos Studio lets you run chaos experiments that intentionally fail part of your application or service to verify that it's resilient against those failures. It can be useful to run these chaos experiments periodically to ensure that your application's resilience hasn't regressed or to meet compliance requirements. In this tutorial, you use a logic app to trigger an experiment to run once a day.

In this tutorial, you learn how to:

  • Create a logic app.
  • Configure the logic app to trigger a chaos experiment to start once a day.
  • Test that the logic app is configured correctly.

Prerequisites

Create a logic app

A logic app is an automated workflow that can execute based on a schedule. The logic app used in this tutorial starts a chaos experiment by using a recurrence schedule.

  1. Sign in to the Azure portal with your Azure account credentials. On the Azure home page, select Create a resource.

  2. On the Azure Marketplace menu, select Integration > Logic App.

    Screenshot that shows the Azure Marketplace menu with Integration and Logic App selected.

  3. On the Create Logic App pane, provide the information described here about the logic app that you want to create.

    Screenshot that shows the Logic App creation pane and the information to provide for the new logic app.

    Property Value Description
    Subscription <Azure-subscription-name> Your Azure subscription name. This example uses Azure Chaos Studio Demo.
    Resource group chaosstudiodemo The name for the Azure resource group, which is used to organize related resources. This example creates a new resource group named chaosstudiodemo.
    Type Consumption The logic app resource type. Set to Consumption.
    Name scheduleExperiment Your logic app's name, which can contain only letters, numbers, hyphens, underscores, parentheses, and periods. This example uses scheduleExperiment.
    Location East US The region where to store your logic app information. This example uses East US.
    Enable log analytics No Set up diagnostic logging for the logic app. Set to No.
  4. When you're done, select Review + create. After Azure validates the information about your logic app, select Create.

  5. After Azure deploys your app, select Go to resource.

    Azure opens the Logic Apps template selection pane, which shows an introduction video, commonly used triggers, and logic app template patterns.

Add the Recurrence trigger

Next, add the Recurrence trigger, which runs the workflow based on a specified schedule. Every logic app must start with a trigger, which fires when a specific event happens or when new data meets a specific condition.

  1. Scroll down past the video and common triggers sections to the Templates section and select Blank Logic App.

    Screenshot that shows the Logic Apps template selection pane with Blank Logic App selected.

  2. In the Logic Apps Designer search box, enter recurrence and select the trigger named Recurrence.

    Screenshot that shows the Logic Apps Designer search box that contains the recurrence search term and in the Triggers list, the Recurrence trigger appears selected.

  3. On the Recurrence shape, select the ellipses (...) button, and then select Rename. Rename the trigger with the description Start chaos experiment every morning.

    Screenshot that shows the ellipses button selected, the Settings list open, and the Rename command selected.

  4. Inside the trigger, change these properties as described and shown here.

    Screenshot that shows the changes to the trigger's interval and frequency.

    Property Required Value Description
    Interval Yes 1 The number of intervals to wait between checks
    Frequency Yes Day The unit of time to use for the recurrence
  5. Under Interval and Frequency, open the Add new parameter list. Select these properties to add to the trigger:

    • At these hours
    • At these minutes

    Screenshot that shows the opened Add new parameter list and these selected properties: On these days, At these hours, and At these minutes.

  6. Now set the values for the properties as shown and described here.

    Screenshot that shows the action properties set to the values as described in the following table.

    Property Value Description
    At these hours 8 This setting is available only when you set the Frequency to Week or Day. For this recurrence, select the hours of the day. This example runs at the 8-hour mark.
    At these minutes 00 This setting is available only when you set the Frequency to Week or Day. For this recurrence, select the minutes of the day. This example runs once at the zero-hour mark.

    This trigger fires every weekday at 8:00 AM. The Preview box shows the recurrence schedule. For more information, see Schedule tasks and workflows and Workflow actions and triggers.

  7. Save your logic app. On the designer toolbar, select Save.

Add a run chaos experiment action

Now that you have a trigger, add an action that starts the experiment. This tutorial uses the Invoke resource operation action to start the experiment.

  1. In the Logic App Designer, under the Recurrence trigger, select New step.

  2. Under Choose an operation, enter Invoke resource operation. Select the option under Actions named Invoke resource operation.

    Screenshot that shows the search bar filled in with Invoke resource operation.

  3. Set the correct Tenant where your experiment is stored and select Sign in.

  4. Sign in to your Azure account for that tenant.

  5. Now set the values for the action properties as shown and described here.

    Screenshot that shows the properties set to the values as described in the following table.

    Property Value Description
    Subscription <Azure-subscription-name> The name of the Azure subscription where your chaos experiment is deployed. This example uses Azure Chaos Studio Demo.
    Resource Group <Resource-group-name> The name for the resource group where your chaos experiment is deployed. This example uses chaosstudiodemo.
    Resource Provider Microsoft.Chaos The Chaos Studio resource provider.
    Short Resource Id experiments/<Resource-group-name> The name of your chaos experiment preceded by experiments/.
    Client Api Version 2023-11-01 The Chaos Studio REST API version.
    Action name start The name of the Chaos Studio experiment action. Always start.
  6. Save your logic app. On the designer toolbar, select Save.

Test the logic app

Now, test the logic app to make sure it successfully starts your experiment.

  1. Close the Logic Apps Designer.

  2. On the logic app overview, select Run Trigger > Run.

    Screenshot that shows the Run Trigger option.

  3. Go to your chaos experiment in the Azure portal and verify that Status is set to Running.

    Screenshot that shows the experiment status.

Clean up resources

If you're not going to continue to use this application, delete the logic app with the following steps:

  1. On the logic app overview, select Delete.
  2. Enter the logic app name and select Delete.

Next steps

Now that you've set a schedule for your experiment, you can: