Azure Chaos Studio 中實驗的 ARM 範本範例
本文包括在 Azure Chaos Studio 中建立混沌實驗的範例 Azure Resource Manager 範本 (ARM 範本)。 每個範例都包含範本檔案和參數檔案,且附有要提供給範本的範例值。
建立實驗 (範例)
在此範例中,我們建立了具有單一目標資源和單一 CPU 壓力錯誤的混沌實驗。 您可以透過參考我們的 REST API 和錯誤程式庫來修改實驗。
部署範本
檢閱範本和參數檔案後,請透過使用 ARM 範本和 Azure 入口網站部署資源一文,了解如何將這些檔案部署到您的 Azure 訂用帳戶。
範本檔案
{
"$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": {}
}
參數檔案
{
"$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"
}
}
}