希望使用 powershell 命令从 azure 应用程序洞察中获取可用性百分比。我有 BASH 命令 az monitor app-insights 指标显示,但由于我想在自动化 Runbook 中运行脚本,它们不支持 BASH 命令。有没有人知道如何使用 PS 命令获得相同的结果?
我最后的选择是使用 invoke-webrequest 或 cURL,但它还有其他挑战,例如 API 密钥。
谢谢
答案 0 :(得分:0)
需要从json file中保存availability.json
并根据需要修改资源并将json保存为来自json file的availert.parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"value": "Replace with your Application Insights resource name"
},
"pingURL": {
"value": "https://www.yoursite.com"
},
"actionGroupId": {
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourceGroup-name/providers/microsoft.insights/actiongroups/replace-with-action-group-name"
},
"location": {
"value": "Replace with the location of your Application Insights resource"
}
}
}
在活动日志中获取actionGroupId
-> 选择特定日志,您可以在此处获取resourceid
。
您可以使用 PowerShell 使用模板和参数文件创建可用性测试和相关警报。
Connect-AzAccount
New-AzResourceGroup -Name AvailabilityAlertDeployment -Location westus2
New-AzResourceGroupDeployment -ResourceGroupName AvailabilityAlertDeployment -TemplateFile ./availabilityalert.json -TemplateParameterFile ./availabilityalert.parameters.json
进一步refer