Quickstart: Create and run a chaos experiment by using Azure Chaos Studio

Get started with Azure Chaos Studio by using a virtual machine (VM) shutdown service-direct experiment to make your service more resilient to that failure in real-world scenarios.

Prerequisites

Register the Chaos Studio resource provider

If it's your first time using Chaos Studio, you must first register the Chaos Studio resource provider before you onboard the resources and create an experiment. You must do these steps for each subscription where you use Chaos Studio:

  1. Open the Azure portal.
  2. Search for Subscriptions and open the subscription management page.
  3. Select the subscription where you want to use Chaos Studio.
  4. In the pane on the left, select Resource providers.
  5. In the list of resource providers that appears, search for Microsoft.Chaos.
  6. Select the Microsoft.Chaos provider and select the Register button.

Create an Azure resource supported by Chaos Studio

Create an Azure resource and ensure that it's one of the supported fault providers. Also validate if this resource is being created in the region where Chaos Studio is available. In this experiment, we choose an Azure VM, which is one of the supported fault providers for Chaos Studio.

Enable Chaos Studio on the VM you created

  1. Open the Azure portal.

  2. Search for Chaos Studio in the search bar.

  3. Select Targets and go to the VM you created.

  4. Select the checkbox next to your VM. Select Enable targets > Enable service-direct targets from the dropdown menu.

    Screenshot that shows the Targets view in the Azure portal.

  5. Confirm that the desired resource is listed. Select Review + Enable, then Enable.

  6. A notification appears and indicates that the resource selected was successfully enabled.

    Screenshot that shows a notification that indicates that targets were successfully enabled.

Create an experiment

  1. Select Experiments.

    Screenshot that shows selecting Experiments.

  2. Select Create > New experiment.

  3. Fill in the Subscription, Resource Group, and Location boxes where you want to deploy the chaos experiment. Give your experiment a name. Select Next: Experiment designer.

    Screenshot that shows adding experiment basics.

  4. In the Chaos Studio experiment designer, give a friendly name to your Step and Branch. Select Add action > Add fault.

    Screenshot that shows the Experiment designer.

  5. Select VM Shutdown from the dropdown list. Then fill in the Duration box with the number of minutes you want the failure to last.

    Screenshot that shows Fault properties.

  6. Select Next: Target resources.

    Screenshot that shows adding a target.

  7. Select Add.

    Screenshot that shows the Add button.

  8. Verify that your experiment looks correct and then select Review + create > Create.

    Screenshot that shows creating the experiment.

Give experiment permission to your VM

  1. Go to your VM and select Access control (IAM).

    Screenshot that shows Access control (IAM) in the left pane.

  2. Select Add.

    Screenshot that shows Add.

  3. Select Add role assignment.

    Screenshot that shows the Add role assignment button.

  4. Search for Virtual Machine Contributor and select the role. Select Next.

    Screenshot that shows choosing the role for the VM.

  5. Select Managed identity option

  6. Choose Select members and search for your experiment name. Select your experiment and choose Select.

    Screenshot that shows selecting the experiment.

  7. Select Review + assign.

Run the chaos experiment

  1. Open the Azure portal:

    • If you're using an @microsoft.com account, go to this website.
    • If you're using an external account, go to this website.
  2. Select the checkbox next to the experiment name and select Start Experiment.

    Screenshot that shows the Start experiment button.

  3. Select Yes to confirm you want to start the chaos experiment.

    Screenshot that shows confirming you want to start an experiment.

  4. (Optional) Select the experiment name to see a detailed view of the execution status of the experiment.

Clean up resources

  1. Select the checkbox next to the experiment name and select Delete.

    Screenshot that shows selecting the experiment to delete.

  2. Select Yes to confirm that you want to delete the experiment.

  3. Search the VM that you created on the Azure portal search bar.

    Screenshot that shows selecting the VM.

  4. Select Delete to avoid being charged for the resource.

    Screenshot that shows deleting the VM.

Next steps

Now that you've run a VM shutdown service-direct experiment, you're ready to: