你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Azure Chaos Studio 中用于试验的 ARM 模板示例
本文包含用于在 Azure Chaos Studio 中创建混沌试验的 Azure 资源管理器模板(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"
}
}
}