Azure Chaos Studio 中實驗的 ARM 範例
本文包含範例 Azure Resource Manager 範本 (ARM 範本) ,以在 Azure Chaos Studio 中建立 混亂實驗 。 每個範例都包含範本檔案和參數檔案,且附有要提供給範本的範例值。
建立實驗(範例)
在此範例中,我們會使用單一目標資源和單一 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"
}
}
}