ARM-mallexempel för experiment i Azure Chaos Studio

Den här artikeln innehåller exempel på Azure Resource Manager-mallar (ARM-mallar) för att skapa ett kaosexperiment i Azure Chaos Studio. Varje exempel innehåller en mallfil och en parameterfil med exempelvärden som ska tillhandahållas mallen.

Skapa ett experiment (exempel)

I det här exemplet skapar vi ett kaosexperiment med en enda målresurs och ett enda CPU-tryckfel. Du kan ändra experimentet genom att referera till vårt REST API och felbibliotek.

Distribuera mallar

När du har granskat mall- och parameterfilerna lär du dig hur du distribuerar dem till din Azure-prenumeration med artikeln Distribuera resurser med ARM-mallar och Azure-portalen .

Mallfil

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "experimentName": {
      "type": "string",
      "defaultValue": "simple-experiment",
      "metadata": {
        "description": "A name for the experiment."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "A region where the experiment will be deployed."
      }
    },
    "chaosTargetResourceId": {
      "type": "string",
      "metadata": {
        "description": "Resource ID of the chaos target. This is the full resource ID of the resource being targeted plus the target proxy resource."
      }
    }
  },
  "functions": [],
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Chaos/experiments",
      "apiVersion": "2024-01-01",
      "name": "[parameters('experimentName')]",
      "location": "[parameters('location')]",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "selectors": [
          {
            "id": "Selector1",
            "type": "List",
            "targets": [
              {
                "type": "ChaosTarget",
                "id": "[parameters('chaosTargetResourceId')]"
              }
            ]
          }
        ],
        "steps": [
          {
            "name": "Step1",
            "branches": [
              {
                "name": "Branch1",
                "actions": [
                  {
                    "duration": "PT10M",
                    "name": "urn:csci:microsoft:agent:cpuPressure/1.0",
                    "parameters": [
                      {
                        "key": "pressureLevel",
                        "value": "95"
                      }
                    ],
                    "selectorId": "Selector1",
                    "type": "continuous"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  ],
  "outputs": {}
}

Parameterfil

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
      "experimentName": {
        "value": "my-first-experiment"
      },
      "location": {
        "value": "eastus"
      },
      "chaosTargetResourceId": {
        "value": "/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.DocumentDB/databaseAccounts/<account-name>/providers/Microsoft.Chaos/targets/microsoft-cosmosdb"
      }
  }
}

Nästa steg