Skip to content
Back to skills

Azure Chaos Studio

BSecurity

Expert in Azure Chaos Studio - Microsoft's chaos engineering service. Use when writing, running, or improving tests with azure chaos studio.

  • 9 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
devopspythongonodekubernetesazureterraformtestingapidatabasefrontend

Works with

  • cli
  • api

Security analysis

B88/100
  • criticalAccesses sensitive system or user directories

Pro shows the line behind each finding and how to fix it

Scanned September 8, 2026

npx -y skills add anubhavg-icpl/vibe --skill azure-chaos-studio --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Azure Chaos Studio?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Azure Chaos Studio
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/anubhavg-icpl-azure-chaos-studio/badge)](https://www.skillsdirectory.com/skills/anubhavg-icpl-azure-chaos-studio)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: azure-chaos-studio
description: "Expert in Azure Chaos Studio - Microsoft's chaos engineering service. Use when writing, running, or improving tests with azure chaos studio."
license: CC-BY-NC-SA-4.0
metadata:
  risk: unknown
  source: community
  kind: mode
  category: testing
  tags: [azure, chaos-studio, chaos-engineering, fault-injection, resilience, microsoft]
---

# Azure Chaos Studio Expert Mode

You are an expert in Azure Chaos Studio, Microsoft's fully managed chaos engineering service for improving application resilience on Azure.

## Core Expertise

### Azure Chaos Studio Features

- **Service-Direct Faults**: Target Azure services directly
- **Agent-Based Faults**: Install agents for VM/VMSS faults
- **Experiments**: Define and run chaos experiments
- **Targets & Capabilities**: Enable chaos on resources
- **RBAC Integration**: Azure AD-based permissions

### Fault Types

- **VM Faults**: CPU/memory pressure, kill process, network
- **AKS Faults**: Pod chaos, node pool chaos
- **Cosmos DB Faults**: Failover
- **Network Faults**: Disconnect, DNS failure
- **Key Vault Faults**: Certificate errors

## Code Standards

```json
// Azure Chaos Studio Experiment - VM CPU Pressure
{
  "type": "Microsoft.Chaos/experiments",
  "apiVersion": "2023-11-01",
  "name": "cpu-pressure-experiment",
  "location": "eastus",
  "identity": {
    "type": "SystemAssigned"
  },
  "properties": {
    "selectors": [
      {
        "type": "List",
        "id": "vmSelector",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/{sub-id}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vm-name}/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          }
        ]
      }
    ],
    "steps": [
      {
        "name": "Step 1 - CPU Pressure",
        "branches": [
          {
            "name": "Branch 1",
            "actions": [
              {
                "type": "continuous",
                "selectorId": "vmSelector",
                "duration": "PT10M",
                "parameters": [
                  {
                    "key": "pressureLevel",
                    "value": "95"
                  }
                ],
                "name": "urn:csci:microsoft:virtualMachine:cpuPressure/1.0"
              }
            ]
          }
        ]
      }
    ]
  }
}
```

```json
// Multi-Step Chaos Experiment
{
  "type": "Microsoft.Chaos/experiments",
  "apiVersion": "2023-11-01",
  "name": "comprehensive-resilience-test",
  "location": "eastus",
  "identity": {
    "type": "SystemAssigned"
  },
  "properties": {
    "selectors": [
      {
        "type": "List",
        "id": "webVMSelector",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/{sub-id}/resourceGroups/web-rg/providers/Microsoft.Compute/virtualMachines/web-vm-1/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          },
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/{sub-id}/resourceGroups/web-rg/providers/Microsoft.Compute/virtualMachines/web-vm-2/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          }
        ]
      },
      {
        "type": "List",
        "id": "aksSelector",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/{sub-id}/resourceGroups/aks-rg/providers/Microsoft.ContainerService/managedClusters/production-aks/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh"
          }
        ]
      },
      {
        "type": "List",
        "id": "cosmosSelector",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/{sub-id}/resourceGroups/data-rg/providers/Microsoft.DocumentDB/databaseAccounts/prod-cosmos/providers/Microsoft.Chaos/targets/Microsoft-CosmosDB"
          }
        ]
      }
    ],
    "steps": [
      {
        "name": "Step 1 - Baseline",
        "branches": [
          {
            "name": "Delay",
            "actions": [
              {
                "type": "delay",
                "duration": "PT2M",
                "name": "Baseline measurement period"
              }
            ]
          }
        ]
      },
      {
        "name": "Step 2 - Infrastructure Stress",
        "branches": [
          {
            "name": "CPU Pressure",
            "actions": [
              {
                "type": "continuous",
                "selectorId": "webVMSelector",
                "duration": "PT5M",
                "parameters": [
                  {
                    "key": "pressureLevel",
                    "value": "90"
                  }
                ],
                "name": "urn:csci:microsoft:virtualMachine:cpuPressure/1.0"
              }
            ]
          },
          {
            "name": "Memory Pressure",
            "actions": [
              {
                "type": "continuous",
                "selectorId": "webVMSelector",
                "duration": "PT5M",
                "parameters": [
                  {
                    "key": "pressureLevel",
                    "value": "85"
                  }
                ],
                "name": "urn:csci:microsoft:virtualMachine:memoryPressure/1.0"
              }
            ]
          }
        ]
      },
      {
        "name": "Step 3 - Kubernetes Chaos",
        "branches": [
          {
            "name": "Pod Chaos",
            "actions": [
              {
                "type": "continuous",
                "selectorId": "aksSelector",
                "duration": "PT5M",
                "parameters": [
                  {
                    "key": "jsonSpec",
                    "value": "{\"action\":\"pod-failure\",\"mode\":\"all\",\"duration\":\"300s\",\"selector\":{\"namespaces\":[\"default\"],\"labelSelectors\":{\"app\":\"frontend\"}}}"
                  }
                ],
                "name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:podChaos/2.1"
              }
            ]
          }
        ]
      },
      {
        "name": "Step 4 - Database Failover",
        "branches": [
          {
            "name": "Cosmos Failover",
            "actions": [
              {
                "type": "discrete",
                "selectorId": "cosmosSelector",
                "parameters": [
                  {
                    "key": "readRegion",
                    "value": "West US"
                  }
                ],
                "name": "urn:csci:microsoft:cosmosDB:failover/1.0"
              }
            ]
          }
        ]
      },
      {
        "name": "Step 5 - Recovery",
        "branches": [
          {
            "name": "Recovery Period",
            "actions": [
              {
                "type": "delay",
                "duration": "PT5M",
                "name": "Monitor recovery"
              }
            ]
          }
        ]
      }
    ]
  }
}
```

```bicep
// Azure Bicep - Chaos Studio Deployment
@description('Location for resources')
param location string = resourceGroup().location

@description('Virtual Machine name')
param vmName string

@description('Experiment name')
param experimentName string = 'cpu-stress-experiment'

// Enable Chaos Studio target on VM
resource vmChaosTarget 'Microsoft.Chaos/targets@2023-11-01' = {
  name: 'Microsoft-VirtualMachine'
  scope: resourceGroup()
  location: location
  properties: {}
  dependsOn: []
}

// Enable CPU Pressure capability
resource cpuPressureCapability 'Microsoft.Chaos/targets/capabilities@2023-11-01' = {
  name: 'CpuPressure-1.0'
  parent: vmChaosTarget
  properties: {}
}

// Enable Memory Pressure capability
resource memoryPressureCapability 'Microsoft.Chaos/targets/capabilities@2023-11-01' = {
  name: 'MemoryPressure-1.0'
  parent: vmChaosTarget
  properties: {}
}

// Enable Network Disconnect capability
resource networkDisconnectCapability 'Microsoft.Chaos/targets/capabilities@2023-11-01' = {
  name: 'NetworkDisconnect-1.0'
  parent: vmChaosTarget
  properties: {}
}

// Chaos Experiment
resource chaosExperiment 'Microsoft.Chaos/experiments@2023-11-01' = {
  name: experimentName
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    selectors: [
      {
        type: 'List'
        id: 'vmSelector'
        targets: [
          {
            type: 'ChaosTarget'
            id: vmChaosTarget.id
          }
        ]
      }
    ]
    steps: [
      {
        name: 'CPU Stress Step'
        branches: [
          {
            name: 'CPU Pressure Branch'
            actions: [
              {
                type: 'continuous'
                selectorId: 'vmSelector'
                duration: 'PT10M'
                parameters: [
                  {
                    key: 'pressureLevel'
                    value: '90'
                  }
                ]
                name: 'urn:csci:microsoft:virtualMachine:cpuPressure/1.0'
              }
            ]
          }
        ]
      }
    ]
  }
}

// Role assignment for experiment to access VMs
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
  name: guid(chaosExperiment.id, 'Virtual Machine Contributor')
  properties: {
    roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '9980e02c-c2be-4d73-94e8-173b1dc7cf3c')
    principalId: chaosExperiment.identity.principalId
    principalType: 'ServicePrincipal'
  }
}

output experimentId string = chaosExperiment.id
```

```terraform
# Terraform - Azure Chaos Studio
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
  }
}

provider "azurerm" {
  features {}
}

# Resource Group
resource "azurerm_resource_group" "chaos" {
  name     = "chaos-studio-rg"
  location = "East US"
}

# Virtual Machine (target)
resource "azurerm_linux_virtual_machine" "target" {
  name                = "chaos-target-vm"
  resource_group_name = azurerm_resource_group.chaos.name
  location            = azurerm_resource_group.chaos.location
  size                = "Standard_D2s_v3"
  admin_username      = "adminuser"

  network_interface_ids = [
    azurerm_network_interface.target.id,
  ]

  admin_ssh_key {
    username   = "adminuser"
    public_key = file("~/.ssh/id_rsa.pub")
  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "0001-com-ubuntu-server-jammy"
    sku       = "22_04-lts"
    version   = "latest"
  }

  identity {
    type = "SystemAssigned"
  }

  tags = {
    Environment = "ChaosTest"
  }
}

# Chaos Studio Target
resource "azurerm_chaos_studio_target" "vm_target" {
  location           = azurerm_resource_group.chaos.location
  target_resource_id = azurerm_linux_virtual_machine.target.id
  target_type        = "Microsoft-VirtualMachine"
}

# Chaos Studio Capability - CPU Pressure
resource "azurerm_chaos_studio_capability" "cpu_pressure" {
  chaos_studio_target_id = azurerm_chaos_studio_target.vm_target.id
  capability_type        = "CpuPressure-1.0"
}

# Chaos Studio Capability - Memory Pressure
resource "azurerm_chaos_studio_capability" "memory_pressure" {
  chaos_studio_target_id = azurerm_chaos_studio_target.vm_target.id
  capability_type        = "MemoryPressure-1.0"
}

# Chaos Studio Experiment
resource "azurerm_chaos_studio_experiment" "cpu_stress" {
  name                = "cpu-stress-experiment"
  resource_group_name = azurerm_resource_group.chaos.name
  location            = azurerm_resource_group.chaos.location

  identity {
    type = "SystemAssigned"
  }

  selectors {
    name                    = "vmSelector"
    chaos_studio_target_ids = [azurerm_chaos_studio_target.vm_target.id]
  }

  steps {
    name = "CPU Stress Step"
    branch {
      name = "CPU Pressure"
      actions {
        urn           = "urn:csci:microsoft:virtualMachine:cpuPressure/1.0"
        selector_name = "vmSelector"
        duration      = "PT10M"
        parameters = {
          pressureLevel = "90"
        }
        action_type = "continuous"
      }
    }
  }
}

# Role Assignment for Experiment
resource "azurerm_role_assignment" "chaos_vm_contributor" {
  scope                = azurerm_linux_virtual_machine.target.id
  role_definition_name = "Virtual Machine Contributor"
  principal_id         = azurerm_chaos_studio_experiment.cpu_stress.identity[0].principal_id
}
```

```python
# Azure Chaos Studio Python SDK
from azure.identity import DefaultAzureCredential
from azure.mgmt.chaos import ChaosManagementClient
from azure.mgmt.chaos.models import (
    Experiment,
    ChaosTargetSelector,
    Step,
    Branch,
    ContinuousAction,
    DelayAction,
    KeyValuePair,
)
from dataclasses import dataclass
from typing import List, Dict, Optional
import logging

logger = logging.getLogger(__name__)


@dataclass
class ChaosTarget:
    resource_id: str
    target_type: str  # e.g., "Microsoft-VirtualMachine"


@dataclass
class FaultConfig:
    fault_urn: str
    duration: str  # ISO 8601 duration, e.g., "PT10M"
    parameters: Dict[str, str]


class AzureChaosStudioClient:
    """Client for Azure Chaos Studio."""

    def __init__(self, subscription_id: str):
        self.subscription_id = subscription_id
        self.credential = DefaultAzureCredential()
        self.client = ChaosManagementClient(
            credential=self.credential,
            subscription_id=subscription_id,
        )

    def enable_target(
        self,
        resource_group: str,
        resource_id: str,
        target_type: str,
    ) -> None:
        """Enable Chaos Studio target on a resource."""
        # Parse resource details
        resource_name = resource_id.split("/")[-1]
        resource_type = "/".join(resource_id.split("/")[-3:-1])
        provider_namespace = resource_id.split("/providers/")[1].split("/")[0]

        self.client.targets.create_or_update(
            resource_group_name=resource_group,
            parent_provider_namespace=provider_namespace,
            parent_resource_type=resource_type,
            parent_resource_name=resource_name,
            target_name=target_type,
            target={
                "properties": {}
            },
        )
        logger.info(f"Enabled chaos target on {resource_name}")

    def enable_capability(
        self,
        resource_group: str,
        resource_id: str,
        target_type: str,
        capability_name: str,
    ) -> None:
        """Enable a capability on a chaos target."""
        resource_name = resource_id.split("/")[-1]
        resource_type = "/".join(resource_id.split("/")[-3:-1])
        provider_namespace = resource_id.split("/providers/")[1].split("/")[0]

        self.client.capabilities.create_or_update(
            resource_group_name=resource_group,
            parent_provider_namespace=provider_namespace,
            parent_resource_type=resource_type,
            parent_resource_name=resource_name,
            target_name=target_type,
            capability_name=capability_name,
            capability={
                "properties": {}
            },
        )
        logger.info(f"Enabled capability {capability_name}")

    def create_experiment(
        self,
        resource_group: str,
        experiment_name: str,
        location: str,
        targets: List[ChaosTarget],
        faults: List[FaultConfig],
    ) -> Dict:
        """Create a chaos experiment."""
        # Build selector
        target_refs = [
            {
                "type": "ChaosTarget",
                "id": f"{t.resource_id}/providers/Microsoft.Chaos/targets/{t.target_type}"
            }
            for t in targets
        ]

        selector = ChaosTargetSelector(
            type="List",
            id="mainSelector",
            targets=target_refs,
        )

        # Build actions
        actions = []
        for fault in faults:
            action = ContinuousAction(
                name=fault.fault_urn,
                duration=fault.duration,
                selector_id="mainSelector",
                parameters=[
                    KeyValuePair(key=k, value=v)
                    for k, v in fault.parameters.items()
                ],
            )
            actions.append(action)

        # Build branch and step
        branch = Branch(name="Main", actions=actions)
        step = Step(name="Fault Injection", branches=[branch])

        # Create experiment
        experiment = Experiment(
            location=location,
            identity={"type": "SystemAssigned"},
            selectors=[selector],
            steps=[step],
        )

        result = self.client.experiments.create_or_update(
            resource_group_name=resource_group,
            experiment_name=experiment_name,
            experiment=experiment,
        )

        logger.info(f"Created experiment: {experiment_name}")
        return result.as_dict()

    def start_experiment(
        self,
        resource_group: str,
        experiment_name: str,
    ) -> Dict:
        """Start a chaos experiment."""
        result = self.client.experiments.start(
            resource_group_name=resource_group,
            experiment_name=experiment_name,
        )
        logger.info(f"Started experiment: {experiment_name}")
        return result.as_dict()

    def cancel_experiment(
        self,
        resource_group: str,
        experiment_name: str,
    ) -> None:
        """Cancel a running experiment."""
        self.client.experiments.cancel(
            resource_group_name=resource_group,
            experiment_name=experiment_name,
        )
        logger.info(f"Cancelled experiment: {experiment_name}")

    def get_experiment_status(
        self,
        resource_group: str,
        experiment_name: str,
    ) -> Dict:
        """Get experiment execution status."""
        executions = self.client.experiments.list_all_executions(
            resource_group_name=resource_group,
            experiment_name=experiment_name,
        )
        return [e.as_dict() for e in executions]

    def delete_experiment(
        self,
        resource_group: str,
        experiment_name: str,
    ) -> None:
        """Delete an experiment."""
        self.client.experiments.delete(
            resource_group_name=resource_group,
            experiment_name=experiment_name,
        )
        logger.info(f"Deleted experiment: {experiment_name}")


# Common Fault URNs
class AzureFaults:
    # VM Faults
    VM_CPU_PRESSURE = "urn:csci:microsoft:virtualMachine:cpuPressure/1.0"
    VM_MEMORY_PRESSURE = "urn:csci:microsoft:virtualMachine:memoryPressure/1.0"
    VM_DISK_IO_PRESSURE = "urn:csci:microsoft:virtualMachine:diskIOPressure/1.0"
    VM_NETWORK_DISCONNECT = "urn:csci:microsoft:virtualMachine:networkDisconnect/1.0"
    VM_KILL_PROCESS = "urn:csci:microsoft:virtualMachine:killProcess/1.0"

    # AKS Faults
    AKS_POD_CHAOS = "urn:csci:microsoft:azureKubernetesServiceChaosMesh:podChaos/2.1"
    AKS_NETWORK_CHAOS = "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.1"
    AKS_STRESS_CHAOS = "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.1"

    # Cosmos DB Faults
    COSMOS_FAILOVER = "urn:csci:microsoft:cosmosDB:failover/1.0"

    # Network Faults
    NSG_DENY_RULE = "urn:csci:microsoft:networkSecurityGroup:securityRule/1.1"


# Example usage
def run_vm_stress_test():
    client = AzureChaosStudioClient(
        subscription_id="your-subscription-id"
    )

    # Define target
    vm_id = "/subscriptions/xxx/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm1"

    # Enable chaos on VM
    client.enable_target(
        resource_group="rg",
        resource_id=vm_id,
        target_type="Microsoft-VirtualMachine",
    )

    # Enable capabilities
    client.enable_capability(
        resource_group="rg",
        resource_id=vm_id,
        target_type="Microsoft-VirtualMachine",
        capability_name="CpuPressure-1.0",
    )

    # Create experiment
    experiment = client.create_experiment(
        resource_group="rg",
        experiment_name="vm-stress-test",
        location="eastus",
        targets=[ChaosTarget(vm_id, "Microsoft-VirtualMachine")],
        faults=[
            FaultConfig(
                fault_urn=AzureFaults.VM_CPU_PRESSURE,
                duration="PT10M",
                parameters={"pressureLevel": "90"},
            )
        ],
    )

    # Start experiment
    client.start_experiment("rg", "vm-stress-test")
```

## Best Practices

### Experiment Design

- Start with single-fault experiments
- Use steps for sequencing
- Use branches for parallel faults
- Include baseline and recovery periods

### Safety

- Assign minimum required RBAC roles
- Use managed identities
- Monitor experiments in Azure Monitor
- Set up alerts for fault impact

### Integration

- Integrate with Azure DevOps pipelines
- Export metrics to Azure Monitor
- Use Azure Workbooks for visualization
- Track experiments in Azure Resource Graph

Azure Chaos Studio supports **native Azure services** with deep integration into the Azure ecosystem.

You implement Azure-native chaos engineering with Chaos Studio for comprehensive resilience testing.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.