Skip to content

Commit ef30d2b

Browse files
committed
Initial creation of portal dynamic targets article
1 parent c4ba04a commit ef30d2b

15 files changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Create a chaos experiment to shut down all targets in a zone
3+
description: Use the Azure portal to create an experiment that uses dynamic targeting to select hosts in a zone
4+
author: rsgel
5+
ms.author: rigel.carlson
6+
ms.service: chaos-studio
7+
ms.topic: how-to
8+
ms.date: 4/3/2023
9+
ms.custom: template-how-to
10+
---
11+
12+
# Create a chaos experiment to shut down all targets in a zone
13+
14+
You can use dynamic targeting in a chaos experiment to choose a set of targets to run an experiment against. This guide shows how you can dynamically target a Virtual Machine Scale Set to shut down based on availability zone. Running this experiment can help you test failover to a Virtual Machine Scale Sets instance in a different region if there's an outage.
15+
16+
These same steps can be used to set up and run an experiment for any fault that supports dynamic targeting. Currently, only Virtual Machine Scale Sets shutdown supports dynamic targeting.
17+
18+
## Prerequisites
19+
20+
- An Azure subscription. [!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
21+
- An Azure Virtual Machine Scale Sets instance.
22+
23+
## Enable Chaos Studio on your Virtual Machine Scale Sets
24+
25+
Chaos Studio can't inject faults against a resource until that resource has been onboarded to Chaos Studio. To onboard a resource to Chaos Studio, create a [target and capabilities](chaos-studio-targets-capabilities.md) on the resource. Virtual Machine Scale Sets only has one target type (`Microsoft-VirtualMachineScaleSet`) and one capability (`shutdown`), but other resources may have up to two target types (one for service-direct faults and one for agent-based faults) and many capabilities.
26+
27+
1. Open the [Azure portal](https://portal.azure.com).
28+
1. Search for **Chaos Studio** in the search bar.
29+
1. Select **Targets** and find your Virtual Machine Scale Sets resource.
30+
1. With the Virtual Machine Scale Sets resource selected, select **Enable targets** and **Enable service-direct targets**.
31+
![A screenshot showing the targets screen within Chaos Studio, with the VMSS resource selected](images/tutorial-dynamic-targets-enable.png)
32+
1. Select **Review + Enable** and **Enable**.
33+
34+
You've now successfully onboarded your Virtual Machine Scale Set to Chaos Studio.
35+
36+
## Create an experiment
37+
38+
With your Virtual Machine Scale Sets now onboarded, you can create your experiment. A chaos experiment defines the actions you want to take against target resources, organized into steps, which run sequentially, and branches, which run in parallel.
39+
40+
1. Within Chaos Studio, navigate to **Experiments** and select **Create**.
41+
![A screenshot showing the Experiments screen, with the Create button highlighted](images/tutorial-dynamic-targets-experiment-browse.png)
42+
1. Add a name for your experiment that complies with resource naming guidelines, and select **Next: experiment designer**.
43+
![A screenshot showing the experiment creation screen, with the Next button highlighted](images/tutorial-dynamic-targets-create-exp.png)
44+
1. Within Step 1 and Branch 1, select **Add action**, then **Add fault**.
45+
![A screenshot showing the experiment creation screen, with the "add fault" button highlighted](images/tutorial-dynamic-targets-experiment-fault.png)
46+
1. Select the **VMSS Shutdown (version 2.0)** fault. Choose your desired duration and whether you want the shutdown to be abrupt, then select **Next: Target resources**.
47+
![A screenshot showing the fault details view](images/tutorial-dynamic-targets-fault-details.png)
48+
1. Choose the Virtual Machine Scale Sets resource that you want to use in the experiment, then select **Next: Scope**.
49+
![A screenshot showing the fault details view, with the VMSS resource selected](images/tutorial-dynamic-targets-fault-resources.png)
50+
1. In the Zones dropdown, select the zone where you want Virtual Machines in the Virtual Machine Scale Sets instance to be shut down.
51+
1. Select **Add** to add the fault to the experiment.
52+
![A screenshot showing the zone selection step within the fault pane](images/tutorial-dynamic-targets-enable.png)
53+
1. Select **Review + create** and then **Create** to save the experiment.
54+
55+
## Give experiment permission to your Virtual Machine Scale Sets
56+
57+
When you create a chaos experiment, Chaos Studio creates a system-assigned managed identity that executes faults against your target resources. This identity must be given [appropriate permissions](chaos-studio-fault-providers.md) to the target resource for the experiment to run successfully. These steps can be used for any resource and target type by modifying the role assignment in step #3 to match the [appropriate role for that resource and target type](chaos-studio-fault-providers.md).
58+
59+
1. Navigate to your Virtual Machine Scale Sets resource and select **Access control (IAM)**.
60+
2. Select **Add role assignment**.
61+
![A screenshot of the Virtual Machine Scale Sets resource page](images/tutorial-dynamic-targets-vmss-iam.png)
62+
3. In the **Role** tab, choose **Virtual Machine Contributor** and then select **Next**.
63+
![A screenshot of the access control overview](images/tutorial-dynamic-targets-role-selection.png)
64+
1. Choose **Select members** and search for your experiment name. Choose your experiment and then **Select**. If there are multiple experiments in the same tenant with the same name, your experiment name is truncated with random characters added.
65+
![A screenshot of the access control overview](images/tutorial-dynamic-targets-role-assignment.png)
66+
1. Select **Review + assign** then **Review + assign**.
67+
![A screenshot of the access control overview](images/tutorial-dynamic-targets-role-confirmation.png)
68+
69+
70+
## Run your experiment
71+
72+
You're now ready to run your experiment!
73+
74+
1. In **Chaos Studio**, navigate to the **Experiments** view, choose your experiment, and select **Start**.
75+
![A screenshot of the access control overview](images/tutorial-dynamic-targets-start-experiment.png)
76+
1. Select **OK** to confirm that you want to start the experiment.
77+
1. When the **Status** changes to **Running**, select **Details** for the latest run under **History** to see details for the running experiment. If any errors occur, you can view them within **Details** by selecting a failed Action and expanding **Failed targets**.
78+
79+
To see the impact, use a tool such as **Azure Monitor** or the **Virtual Machine Scale Sets** section of the portal to check if your Virtual Machine Scale Sets targets are shut down. If they're shut down, check to see that the services running on your Virtual Machine Scale Sets are still running as expected.
80+
81+
In this example, the chaos experiment successfully shut down the instance in Zone 1, as expected.
82+
![A screenshot of the access control overview](images/tutorial-dynamic-targets-view-vmss.png)
83+
84+
85+
## Next steps
86+
Now that you've run a dynamically targeted Virtual Machine Scale Sets shutdown experiment, you're ready to:
87+
- [Create an experiment that uses agent-based faults](chaos-studio-tutorial-agent-based-portal.md)
88+
- [Manage your experiment](chaos-studio-run-experiment.md)
89+
301 KB
Loading
253 KB
Loading
305 KB
Loading
233 KB
Loading
217 KB
Loading
335 KB
Loading
425 KB
Loading
314 KB
Loading
208 KB
Loading

0 commit comments

Comments
 (0)