Application Insights 与 Log Analytics 集成,并将遥测数据发送到常见的 Log Analytics 工作区。 此设置提供对 Log Analytics 功能的完全访问权限,将日志合并到一个位置,并允许使用统一的 Azure 基于角色的访问控制 ,从而无需跨应用/工作区查询。
增强的功能包括:
- 客户管理的密钥 - 使用仅可访问的密钥加密静态数据。
- Azure 专用链接 - 使用专用终结点将 Azure PaaS 服务安全连接到虚拟网络。
- - 此层级提供的定价相对于即用即付定价而言可以节省高达 30% 的费用。
本文介绍如何创建和配置 Application Insights 资源。 除了 Application Insights 资源本身,还可以添加各种配置,例如设置 每日 上限和 定价计划。 还可以使用 Azure 资源管理器创建可用性测试、设置指标警报并自动执行该过程。
注意
基于工作区的 Application Insights 资源的数据引入和保留操作通过数据所在的 Log Analytics 工作区计费。 若要了解有关计费的详细信息,请参阅 Azure Monitor 日志定价详细信息。
先决条件
其他需求
若要访问 Application Insights Azure CLI 命令,首先需要运行:
az extension add -n application-insights
如果不运行 az extension add
命令,则会看到一条错误消息,指出 az : ERROR: az monitor: 'app-insights' is not in the 'az monitor' command group. See 'az monitor --help'
。
可以通过 Azure CLI、Azure PowerShell 和 Azure 门户中部署 Bicep 模板。 检查相应的选项卡,了解其他要求。
可以通过 Azure CLI、Azure PowerShell 和 Azure 门户中部署 ARM 模板。 检查相应的选项卡,了解其他要求。
创建 Application Insights 资源
- 登录到 Azure 门户。
- 选择“创建资源”。
- 然后选择 Application Insights。
- 输入所有相关信息,然后 审核并创建 Application Insights 资源。
注意
如果在创建资源期间未连接到现有的 Log Analytics 工作区,则会随 Application Insights 资源一起自动创建新的 Log Analytics 资源。
创建资源后,可以在 Application Insights “概述 ”窗格中找到相应的工作区信息。
选择蓝色的链接文本会转到关联的 Log Analytics 工作区,可以在其中利用新的统一工作区查询环境。
备注
我们仍为 Application Insights 经典资源查询、工作簿和基于日志的警报提供完全后向兼容性。 若要查询或查看新的基于工作区的表结构或架构,必须先转到 Log Analytics 工作区。 在“Application Insights”窗格中选择“日志(分析)”访问经典 Application Insights 查询体验。
若要创建基于工作区的 Application Insights 资源,需要 Log Analytics 工作区。 如果还没有,可以使用以下 Azure CLI 命令创建一个。
占位符:<resource-group-name>
、、 <log-analytics-workspace-name>
<azure-region-name>
az monitor log-analytics workspace create --resource-group <resource-group-name> --workspace-name <log-analytics-workspace-name> --location <azure-region-name>
若要创建 Application Insights 资源,请在终端中运行以下 Azure CLI 命令。
占位符:<application-insights-resource-name>
、、<azure-region-name>
<resource-group-name>
、<log-analytics-workspace-name>
az monitor app-insights component create --app <application-insights-resource-name> --location <azure-region-name> --resource-group <resource-group-name> --workspace <log-analytics-workspace-name>
有关使用 Azure CLI 创建 Application Insights 资源和 Log Analytics 工作区的详细信息,请参阅 Application Insights 和 Log Analytics的 Azure CLI 文档。
若要创建基于工作区的 Application Insights 资源,需要 Log Analytics 工作区。 如果还没有,可以使用以下 Azure PowerShell 命令创建一个。
占位符:<resource-group-name>
、、 <log-analytics-workspace-name>
<azure-region-name>
New-AzOperationalInsightsWorkspace -ResourceGroupName <resource-group-name> -Name <log-analytics-workspace-name> -Location <azure-region-name>
若要创建 Application Insights 资源,请在终端中运行以下 Azure PowerShell 命令。
占位符:<resource-group-name>
、、<application-insights-resource-name>
<azure-region-name>
、<subscription-id>
、<log-analytics-workspace-name>
New-AzApplicationInsights -ResourceGroupName <resource-group-name> -Name <application-insights-resource-name> -Location <azure-region-name> -WorkspaceResourceId /subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>
有关使用 Azure PowerShell 创建 Application Insights 资源和 Log Analytics 工作区的详细信息,请参阅适用于 Application Insights 和 Log Analytics的 Azure PowerShell 文档。
若要创建基于工作区的 Application Insights 资源,需要 Log Analytics 工作区。 如果没有,可以使用以下 REST API 调用创建一个。
占位符:<subscription-id>
、、<resource-group-name>
<log-analytics-workspace-name>
、<access-token>
、<azure-region-name>
PUT https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>?api-version=2023-09-01
Authorization: Bearer <access-token>
Content-Type: application/json
{
"location": "<azure-region-name>"
}
若要使用 REST API 创建 Application Insights 资源,请使用以下请求。
占位符:<subscription-id>
、、<resource-group-name>
、<application-insights-resource-name>
<access-token>
、<application-type>
、<azure-region-name>
、<log-analytics-workspace-name>
PUT https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Insights/components/<application-insights-resource-name>?api-version=2020-02-02
Authorization: Bearer <access-token>
Content-Type: application/json
{
"kind": "<application-type>",
"location": "<azure-region-name>",
"properties": {
"Application_Type": "<application-type>",
"WorkspaceResourceId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>"
}
}
有关使用 REST API 创建 Application Insights 资源和 Log Analytics 工作区的详细信息,请参阅 Application Insights 和 Log Analytics的 REST API 文档。
下面介绍如何使用 Bicep 模板创建新的 Application Insights 资源。
创建模板
创建新的 .bicep 文件(例如 my-template.bicep),将以下内容复制到其中:
param name string
param type string
param regionId string
param requestSource string
param workspaceResourceId string
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: name
location: regionId
tags: tagsArray
kind: 'other'
properties: {
Application_Type: type
Request_Source: requestSource
WorkspaceResourceId: workspaceResourceId
}
}
创建参数文件
创建新的 .bicepparam 文件(例如 my-parameters.bicepparam),将以下内容复制到其中,并将占位符 <application-insights-resource-name>
、 <application-type>
、 <azure-region-name>
、 <subscription-id>
、 <resource-group-name>
以及 <log-analytics-workspace-name>
替换为特定值:
using 'my-template.bicep'
param name string = '<application-insights-resource-name>'
param type string = '<application-type>'
param regionId string = '<azure-region-name>'
param requestSource string = 'CustomDeployment'
param workspaceResourceId string = '/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<log-analytics-workspace-name>'
使用模板创建新的 Application Insights 资源
在 PowerShell 中,使用 $Connect-AzAccount
登录 Azure。
使用 Set-AzContext "<subscription ID>"
将上下文设置为某个订阅。
运行新的部署来新建 Application Insights 资源:
New-AzResourceGroupDeployment -ResourceGroupName <your-resource-group> -TemplateFile my-template.bicep -TemplateParameterFile my-parameters.bicepparam
-ResourceGroupName
是您要在其中创建新资源的组。
-TemplateFile
必须在自定义参数前出现。
-TemplateParameterFile
是参数文件的名称。
可以添加其他参数。 可在模板的参数部分找到说明。
下面介绍如何使用 ARM 模板创建新的 Application Insights 资源。
创建模板
创建新的 .json 文件(例如 ,my-template.json),并将以下内容复制到其中:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"metadata": {
"description": "Name of Application Insights resource."
}
},
"type": {
"type": "string",
"metadata": {
"description": "Type of app you are deploying. This field is for legacy reasons and will not impact the type of Application Insights resource you deploy."
}
},
"regionId": {
"type": "string",
"metadata": {
"description": "Which Azure region to deploy the resource to. This must be a valid Azure regionId."
}
},
"tagsArray": {
"type": "object",
"metadata": {
"description": "See documentation on tags: https://learn.microsoft.com/azure/azure-resource-manager/management/tag-resources."
}
},
"requestSource": {
"type": "string",
"metadata": {
"description": "Source of Azure Resource Manager deployment"
}
},
"workspaceResourceId": {
"type": "string",
"metadata": {
"description": "Log Analytics workspace ID to associate with your Application Insights resource."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[parameters('name')]",
"location": "[parameters('regionId')]",
"tags": "[parameters('tagsArray')]",
"kind": "other",
"properties": {
"Application_Type": "[parameters('type')]",
"Request_Source": "[parameters('requestSource')]",
"WorkspaceResourceId": "[parameters('workspaceResourceId')]"
}
}
]
}
注意
有关资源属性的详细信息,请参阅属性值。
不会使用 Flow_Type
和 Request_Source
,但出于完整性,已将其包含在此示例中。
创建参数文件
创建新的 .json 文件(例如, my-parameters.json),将以下内容复制到其中,并将占位符 <application-insights-resource-name>
、 <application-type>
、 <azure-region-name>
、 <subscription-id>
、 <resource-group-name>
以及 <log-analytics-workspace-name>
替换为特定值:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<application-insights-resource-name>"
},
"type": {
"value": "<application-type>"
},
"regionId": {
"value": "<azure-region-name>"
},
"tagsArray": {
"value": {}
},
"requestSource": {
"value": "CustomDeployment"
},
"workspaceResourceId": {
"value": "/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<log-analytics-workspace-name>"
}
}
}
使用模板创建新的 Application Insights 资源
在 PowerShell 中,使用 $Connect-AzAccount
登录 Azure。
使用 Set-AzContext "<subscription ID>"
将上下文设置为某个订阅。
运行新的部署来新建 Application Insights 资源:
New-AzResourceGroupDeployment -ResourceGroupName <your-resource-group> -TemplateFile my-template.json -TemplateParameterFile my-parameters.json
-ResourceGroupName
是您要在其中创建新资源的组。
-TemplateFile
必须在自定义参数前出现。
-TemplateParameterFile
是参数文件的名称。
创建 Application Insights 资源后,可以配置监视。
获取连接字符串
连接字符串用于标识要与遥测数据关联的资源。 还可以使用它来修改你的资源用作遥测目标的终结点。 必须复制连接字符串,并将其添加到应用程序的代码或添加到环境变量中。
若要获取 Application Insights 资源的连接字符串,请执行以下操作:
- 在 Azure 门户中打开 Application Insights 资源。
- 在“概要”部分中的“概述”窗格中,查找连接字符串。
- 如果将鼠标悬停在连接字符串上,将显示一个图标,用于将其复制到剪贴板。
若要获取连接字符串,请在终端中运行以下 Azure CLI 命令,并将占位符 <application-insights-resource-name>
和 <resource-group-name>
替换为您的特定值:
az monitor app-insights component show --app <application-insights-resource-name> --resource-group <resource-group-name> --query connectionString --output tsv
有关命令的详细信息 az monitor app-insights component show
,请参阅 Azure CLI 文档。
若要获取连接字符串,请在终端中运行以下 Azure PowerShell 命令,并将占位符 <resource-group-name>
和 <application-insights-resource-name>
替换为你的具体值。
Get-AzApplicationInsights -ResourceGroupName <resource-group-name> -Name <application-insights-resource-name> | Select-Object -ExpandProperty ConnectionString
有关该命令的详细信息 Get-AzApplicationInsights
,请参阅 Azure PowerShell 文档。
若要检索 Application Insights 资源的详细信息,请使用以下请求,并将占位符 <subscription-id>
、<resource-group-name>
、<application-insights-resource-name>
和 <access-token>
替换为您的特定值:
GET https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Insights/components/<application-insights-resource-name>?api-version=2015-05-01
Authorization: Bearer <access-token>
在 JSON 响应中查找 properties.connectionString
字段。
有关使用 REST API 检索有关 Application Insights 资源的信息的详细信息,请参阅 REST API 文档。
使用 OpenTelemetry 进行应用程序监视
若要使用 OpenTelemetry 进行应用程序监视,请安装相应的 Azure Monitor OpenTelemetry 发行版,并将连接字符串指向新创建的资源。
有关如何使用 OpenTelemetry 设置应用程序监视的信息,请参阅特定于语言的以下文档:
自动化仪器
对于 Azure Functions 和 Azure 应用服务等监视服务,可以先创建 Application Insights 资源,然后在启用监视时指向它。 或者,可以在启用过程中创建新的 Application Insights 资源。
修改关联的工作区
创建 Application Insights 资源后,可以修改关联的 Log Analytics 工作区。
在 Application Insights 资源中,选择 属性>更改工作区>Log Analytics 工作区。
若要更改 Log Analytics 工作区,请在终端中运行以下 Azure CLI 命令,并将占位符<application-insights-resource-name>
<resource-group-name>
<log-analytics-workspace-name>
替换为特定值:
az monitor app-insights component update --app <application-insights-resource-name> --resource-group <resource-group-name> --workspace <log-analytics-workspace-name>
有关命令的详细信息 az monitor app-insights component update
,请参阅 Azure CLI 文档。
若要更改 Log Analytics 工作区,请在终端中运行以下 Azure PowerShell 命令,并将占位符 <resource-group-name>
、<application-insights-resource-name>
、<subscription-id>
和 <log-analytics-workspace-name>
替换为您特定的值。
Update-AzApplicationInsights -ResourceGroupName <resource-group-name> -Name <application-insights-resource-name> -WorkspaceResourceId /subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>
有关该命令的详细信息 Update-AzApplicationInsights
,请参阅 Azure PowerShell 文档。
若要使用 REST API 更改 Log Analytics 工作区,请使用以下请求并将占位符<subscription-id>
、<resource-group-name>
、<application-insights-resource-name>
、<access-token>
、以及<azure-region-name>
<log-analytics-workspace-name>
替换为特定值:
PATCH https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Insights/components/<application-insights-resource-name>?api-version=2020-02-02
Authorization: Bearer <access-token>
Content-Type: application/json
{
"location": "<azure-region-name>",
"properties": {
"WorkspaceResourceId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>"
}
}
有关使用 REST API 修改关联工作区的详细信息,请参阅 REST API 文档。
若要更改 Log Analytics 工作区,请将以下代码粘贴到模板中,并将占位符 <application-insights-resource-name>
、<azure-region-name>
、<application-type>
和 <log-analytics-workspace-name>
替换为您的特定值。
param workspaceResourceId string = '/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>'
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
name: '<application-insights-resource-name>'
location: '<azure-region-name>'
properties: {
Application_Type: '<application-type>'
WorkspaceResourceId: workspaceResourceId
}
}
若要更改 Log Analytics 工作区,请将以下代码粘贴到模板中,并将占位符 <application-insights-resource-name>
、<azure-region-name>
、<application-type>
和 <log-analytics-workspace-name>
替换为您的特定值。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02-preview",
"name": "<application-insights-resource-name>",
"location": "<azure-region-name>",
"properties": {
"Application_Type": "<application-type>",
"WorkspaceResourceId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>"
}
}
]
}
导出遥测数据
基于工作区的资源不支持旧版连续导出功能。 请改用 诊断设置。
在 Application Insights 资源中,选择“ 诊断设置>添加诊断设置”。
可以选择要存档到存储帐户的所有表或表子集。 还可以将其流式传输到事件中心。
若要使用诊断设置导出遥测数据,请在终端中运行以下 Azure CLI 命令,并将占位符 <diagnostic-setting-name>
、<application-insights-resource-name>
、<resource-group-name>
和 <storage-account-name>
替换为特定值:
az monitor diagnostic-settings create --name <diagnostic-setting-name> --resource <application-insights-resource-name> --resource-group <resource-group-name> --resource-type Microsoft.Insights/components --storage-account <storage-account-name>
此示例命令启用诊断设置,并将 Application Insights 资源的所有日志发送到指定的存储帐户。 若要发送指标,请将 --metrics '[{"category": "AllMetrics", "enabled": true}]'
添加到命令。
有关命令的详细信息 az monitor diagnostic-settings create
,请参阅 Azure CLI 文档。
若要使用诊断设置导出遥测数据,请在终端中运行以下 Azure PowerShell 命令,并将占位符<application-insights-resource-id>
<diagnostic-setting-name>
<storage-account-id>
替换为特定值:
Set-AzDiagnosticSetting -ResourceId <application-insights-resource-id> -Name <diagnostic-setting-name> -StorageAccountId <storage-account-id> -Enabled $True
此示例命令启用诊断设置,并将 Application Insights 资源的所有指标和日志发送到指定的存储帐户。
有关该命令的详细信息 Set-AzDiagnosticSetting
,请参阅 Azure PowerShell 文档。
若要使用诊断设置将遥测数据导出到 Azure 存储帐户,请使用以下请求并将占位符<subscription-id>
、<resource-group-name>
、<application-insights-resource-name>
、<diagnostic-setting-name>
、以及<access-token>
<storage-account-name>
替换为特定值:
PUT https://management.chinacloudapi.cn//subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>/providers/Microsoft.Insights/diagnosticSettings/<diagnostic-setting-name>?api-version=2021-05-01-preview
Authorization: Bearer <access-token>
Content-Type: application/json
{
"properties": {
"storageAccountId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>",
"logs": [
{
"category": "AppRequests",
"enabled": true
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true
}
]
}
}
此示例调用启用诊断设置,并将 Application Insights 资源的所有指标和日志发送到指定的存储帐户。
有关使用 REST API 创建诊断设置的详细信息,请参阅 REST API 文档。
若要使用诊断设置导出遥测数据,请将以下代码粘贴到模板中,并将占位符<application-insights-resource-name>
、<azure-region-name>
、<application-type>
、<diagnostic-setting-name>
、<subscription-id>
、以及<resource-group>
<storage-account-name>
替换为特定值:
param appInsightsName string = '<application-insights-resource-name>'
param location string = '<azure-region-name>'
param applicationType string = '<application-type>'
param diagnosticSettingName string = '<diagnostic-setting-name>'
param storageAccountId string = '/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>'
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: appInsightsName
location: location
kind: applicationType
properties: {
Application_Type: applicationType
}
}
resource diagnosticSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagnosticSettingName
scope: appInsights
properties: {
storageAccountId: storageAccountId
logs: [
{
category: 'AppRequests'
enabled: true
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
}
]
}
}
若要使用诊断设置导出遥测数据,请将以下代码粘贴到模板中,并将占位符<application-insights-resource-name>
、<azure-region-name>
、<application-type>
、<diagnostic-setting-name>
、<subscription-id>
、以及<resource-group>
<storage-account-name>
替换为特定值:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsName": {
"type": "string",
"defaultValue": "<application-insights-resource-name>"
},
"location": {
"type": "string",
"defaultValue": "<azure-region-name>"
},
"applicationType": {
"type": "string",
"defaultValue": "<application-type>"
},
"diagnosticSettingName": {
"type": "string",
"defaultValue": "<diagnostic-setting-name>"
},
"storageAccountId": {
"type": "string",
"defaultValue": "/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>"
}
},
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[parameters('appInsightsName')]",
"location": "[parameters('location')]",
"kind": "[parameters('applicationType')]",
"properties": {
"Application_Type": "[parameters('applicationType')]"
}
},
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2021-05-01-preview",
"name": "[parameters('diagnosticSettingName')]",
"scope": "[resourceId('Microsoft.Insights/components', parameters('appInsightsName'))]",
"properties": {
"storageAccountId": "[parameters('storageAccountId')]",
"logs": [
{
"category": "AppRequests",
"enabled": true
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true
}
]
}
}
]
}
设置数据保留期
若要为关联的 Log Analytics 工作区设置数据保留期,请将以下代码粘贴到模板中,并将占位符 <log-analytics-workspace-name>
、<azure-region-name>
、<retention-period-in-days>
替换为特定值:
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: '<log-analytics-workspace-name>'
location: '<azure-region-name>'
properties: {
retentionInDays: <retention-period-in-days>
}
}
若要为关联的 Log Analytics 工作区设置数据保留期,请将以下代码粘贴到模板中,并将占位符 <log-analytics-workspace-name>
、<azure-region-name>
、<retention-period-in-days>
替换为特定值:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"name": "<log-analytics-workspace-name>",
"location": "<azure-region-name>",
"properties": {
"retentionInDays": <retention-period-in-days>
}
}
]
}
设置每日上限
必须为 Application Insights 和基础 Log Analytics 工作区单独设置每日上限。 有效的每日上限是两个设置的最小值。
注意
目前,Azure 不提供通过 Azure CLI 为 Application Insights 设置每日上限的方法。
若要更改 Log Analytics 的每日上限,请在终端中运行以下 Azure CLI 命令,并将占位符<resource-group-name>
<log-analytics-workspace-name>
<daily-cap-in-gb>
替换为特定值。
az monitor log-analytics workspace update --resource-group <resource-group-name> --workspace-name <log-analytics-workspace-name> --set workspaceCapping.dailyQuotaGb=<daily-cap-in-gb>
有关命令的详细信息 az monitor log-analytics workspace update
,请参阅 Azure CLI 文档。
若要更改 Application Insights 和 Log Analytics 的每日上限,请在终端中运行以下 Azure PowerShell 命令,并将占位符替换为特定值。
Application Insights
占位符:<resource-group-name>
、、 <application-insights-resource-name>
<daily-cap-in-gb>
Set-AzApplicationInsightsDailyCap -ResourceGroupName <resource-group-name> -Name <application-insights-resource-name> -DailyCapGB <daily-cap-in-gb>
有关该命令的详细信息 Set-AzApplicationInsightsDailyCap
,请参阅 Azure PowerShell 文档。
Log Analytics
占位符:<resource-group-name>
、、 <log-analytics-workspace-name>
<daily-cap-in-gb>
Set-AzOperationalInsightsWorkspace -ResourceGroupName <resource-group-name> -Name <log-analytics-workspace-name> -DailyQuotaGb <daily-cap-in-gb>
有关该命令的详细信息 Set-AzOperationalInsightsWorkspace
,请参阅 Azure PowerShell 文档。
注意
目前,Azure 不提供使用 Azure CLI 为 Application Insights 设置每日上限的方法。
若要更改 Log Analytics 的每日上限,请使用以下请求,并将占位符 <subscription-id>
、 <resource-group-name>
、 <log-analytics-workspace-name>
、 <access-token>
、 <azure-region-name>
以及 <daily-cap-in-gb>
替换为特定值:
占位符:
PATCH https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>?api-version=2023-09-01
Authorization: Bearer <access-token>
Content-Type: application/json
{
"location": '<azure-region-name>',
"properties": {
"workspaceCapping": {
"dailyQuotaGb": <daily-cap-in-gb>,
},
}
}
有关 Log Analytics 每日上限设置的详细信息,请参阅 REST API 文档
注意
目前,Azure 不提供使用 Bicep 模板为 Application Insights 设置每日上限的方法。
若要设置 Log Analytics 的每日上限,请将以下代码粘贴到模板中,并将占位符<log-analytics-workspace-name>
<azure-region-name>
<daily-cap-in-gb>
替换为特定值:
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: '<log-analytics-workspace-name>'
location: '<azure-region-name>'
properties: {
dailyQuotaGb: <daily-cap-in-gb>
}
}
注意
目前,Azure 不提供使用 ARM 模板为 Application Insights 设置每日上限的方法。
若要设置 Log Analytics 的每日上限,请将以下代码粘贴到模板中,并将占位符<log-analytics-workspace-name>
<azure-region-name>
<daily-cap-in-gb>
替换为特定值:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2023-09-01",
"name": "<log-analytics-workspace-name>",
"location": "<azure-region-name>",
"properties": {
"workspaceCapping": {
"dailyQuotaGb": <daily-cap-in-gb>
}
}
}
]
}
设置定价计划
可以在关联的 Log Analytics 工作区中设置 Application Insights 资源的定价计划。 有关可用定价计划的详细信息,请参阅 Azure Monitor 日志成本计算和选项。
若要设置定价计划,请在终端中运行以下 Azure CLI 命令之一,并将占位符<log-analytics-workspace-name>
<azure-region-name>
替换为特定值(如果适用<capacity-reservation-in-gb>
):
即用即付
az monitor log-analytics workspace update --resource-group <resource-group-name> --workspace-name <log-analytics-workspace-name> --set PerGB2018
承诺层
az monitor log-analytics workspace update --resource-group <resource-group-name> --workspace-name <log-analytics-workspace-name> --set CapacityReservation --level <capacity-reservation-in-gb>
有关命令的详细信息 az monitor log-analytics workspace update
,请参阅 Azure CLI 文档。
若要设置定价计划,请在终端中运行以下 Azure PowerShell 命令之一,并将占位符<log-analytics-workspace-name>
<azure-region-name>
替换为特定值(如果适用<capacity-reservation-in-gb>
):
即用即付
Set-AzOperationalInsightsWorkspace -ResourceGroupName <resource-group-name> -Name <log-analytics-workspace-name> -Sku perb2018
承诺层
Set-AzOperationalInsightsWorkspace -ResourceGroupName <resource-group-name> -Name <log-analytics-workspace-name> -Sku capacityreservation -SkuCapacity <capacity-reservation-in-gb>
有关该命令的详细信息 Set-AzOperationalInsightsWorkspace
,请参阅 Azure PowerShell 文档。
若要使用 REST API 设置定价计划,请使用以下请求之一,并将占位符<subscription-id>
、<resource-group-name>
、<log-analytics-workspace-name>
<access-token>
和(如果适用)<capacity-reservation-in-gb>
替换为特定值:
即用即付
PUT https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>/pricingPlans/current?api-version=2017-10-01
Content-Type: application/json
Authorization: Bearer <access-token>
{
"properties": {
"sku": {
"name": "pergb2018"
}
}
}
承诺层
PUT https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.OperationalInsights/workspaces/<log-analytics-workspace-name>/pricingPlans/current?api-version=2017-10-01
Content-Type: application/json
Authorization: Bearer <access-token>
{
"properties": {
"sku": {
"name": "capacityreservation",
"capacityReservationLevel": <capacity-reservation-in-gb>
}
}
}
有关使用 REST API 设置定价计划的详细信息,请参阅 REST API 文档。
若要使用 Bicep 设置定价计划,请将以下代码粘贴到模板中,并替换占位符 <log-analytics-workspace-name>
、<azure-region-name>
,对于承诺层,还需替换 <capacity-reservation-in-gb>
为您的特定值:
即用即付
param workspaceName string = '<log-analytics-workspace-name>'
param workspaceRegion string = '<azure-region-name>'
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: workspaceName
location: workspaceRegion
properties: {
sku: {
name: 'pergb2018'
}
}
}
承诺层
param workspaceName string = '<log-analytics-workspace-name>'
param workspaceRegion string = '<azure-region-name>'
param capacityReservationLevel int = '<capacity-reservation-in-gb>'
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: workspaceName
location: workspaceRegion
properties: {
sku: {
name: 'capacityreservation'
capacityReservationLevel: capacityReservationLevel
}
}
}
有关使用 Bicep 更新 Microsoft.OperationalInsights/workspaces
资源的详细信息,请参阅 模板文档。
若要使用 ARM 模板设置定价计划,请将以下代码粘贴到模板中,并用你的具体值替换占位符 <log-analytics-workspace-name>
和 <azure-region-name>
。对于承诺层次,也需替换 <capacity-reservation-in-gb>
。
即用即付
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceName": {
"type": "string",
"defaultValue": "<log-analytics-workspace-name>"
},
"workspaceRegion": {
"type": "string",
"defaultValue": "<azure-region-name>"
}
},
"resources": [
{
"name": "[parameters('workspaceName')]",
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"location": "[parameters('workspaceRegion')]",
"properties": {
"sku": {
"name": "pergb2018"
}
}
}
]
}
承诺层
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceName": {
"type": "string",
"defaultValue": "<log-analytics-workspace-name>"
},
"workspaceRegion": {
"type": "string",
"defaultValue": "<azure-region-name>"
},
"capacityReservationLevel": {
"type": "int",
"defaultValue": <capacity-reservation-in-gb>
}
},
"resources": [
{
"name": "[parameters('workspaceName')]",
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"location": "[parameters('workspaceRegion')]",
"properties": {
"sku": {
"name": "capacityreservation",
"capacityReservationLevel": "[parameters('capacityReservationLevel')]"
}
}
}
]
}
有关使用 ARM 模板更新 Microsoft.OperationalInsights/workspaces
资源的详细信息,请参阅 模板文档。
禁用 IP 掩码
默认情况下,Application Insights 不会存储 IP 地址。 若要了解如何禁用 IP 掩码,请参阅 地理位置和 IP 地址处理。
创建其他资源
创建可用性测试
若要使用默认设置创建标准可用性测试,请在终端中运行以下 Azure CLI 命令,并将占位符<resource-group-name>
、<azure-region-name>
、<web-test-name>
、<url>
以及<subscription-id>
<application-insights-resource-name>
替换为特定值:
az monitor app-insights web-test create --resource-group <resource-group-name> \
--location <azure-region-name> \
--web-test-kind standard \
--name <web-test-name> \
--defined-web-test-name <web-test-name> \
--request-url <url> \
--retry-enabled true \
--ssl-check true \
--ssl-lifetime-check 7 \
--frequency 300 \
--locations Id="us-ca-sjc-azr" \
--locations Id="apac-sg-sin-azr" \
--locations Id="us-il-ch1-azr" \
--locations Id="us-va-ash-azr" \
--locations Id="emea-au-syd-edge" \
--http-verb GET \
--timeout 120 \
--expected-status-code 200 \
--enabled true \
--tags hidden-link:/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>=Resource
有关命令的详细信息 az monitor app-insights web-test create
,请参阅 Azure CLI 文档。
注意
Web 测试区域(-location
)与地理位置(-locations
)不同,后者可以选择多个(注意复数形式)。 -location
指的是创建和托管 Web 测试的 Azure 区域,同时 -locations
指的是从中执行 Web 测试的地理位置或位置。 有关所有地理位置的完整列表,请参阅 Application Insights 可用性测试。
若要使用默认设置创建标准可用性测试,请在终端中运行以下 Azure PowerShell 命令,并将占位符<resource-group-name>
、<azure-region-name>
、<web-test-name>
、<url>
以及<subscription-id>
<application-insights-resource-name>
替换为特定值:
$geoLocation = @()
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-ca-sjc-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "apac-sg-sin-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-il-ch1-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "us-va-ash-azr"
$geoLocation += New-AzApplicationInsightsWebTestGeolocationObject -Location "emea-au-syd-edge"
New-AzApplicationInsightsWebTest -ResourceGroupName <resource-group-name> `
-Location <azure-region-name> `
-Name <web-test-name> `
-TestName <web-test-name> `
-Kind standard `
-RequestUrl <url> `
-RetryEnabled `
-RuleSslCheck `
-RuleSslCertRemainingLifetimeCheck 7 `
-Frequency 300 `
-GeoLocation $geoLocation `
-RequestHttpVerb GET `
-Timeout 120 `
-RuleExpectedHttpStatusCode 200 `
-Enabled `
-Tag @{"hidden-link:/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>" = "Resource"}
有关该命令的详细信息 New-AzApplicationInsightsWebTest
,请参阅 Azure PowerShell 文档。
注意
Web 测试区域(-Location
)不同于可以选择多个区域的地理位置(-GeoLocation
)。 -Location
是指创建和托管 Web 测试的 Azure 区域,同时 -GeoLocation
引用执行 Web 测试的地理位置或位置。 有关所有地理位置的完整列表,请参阅 Application Insights 可用性测试。
若要使用 REST API 使用默认设置创建标准可用性测试,请使用以下请求,并将占位符<subscription-id>
、<resource-group-name>
、<application-insights-resource-name>
、<web-test-name>
、<access-token>
以及<azure-region-name>
<url>
替换为特定值:
PUT https://management.chinacloudapi.cn/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>/webtests/<web-test-name>?api-version=2021-08-01
Content-Type: application/json
Authorization: Bearer <access-token>
{
"location": "<azure-region-name>",
"properties": {
"Name": "<web-test-name>",
"SyntheticMonitorId": "<web-test-name>",
"Enabled": true,
"Frequency": 300,
"Timeout": 120,
"Kind": "standard",
"RetryEnabled": true,
"Request": {
"RequestUrl": "<url>",
"HttpVerb": "GET"
},
"ValidationRules": {
"ExpectedHttpStatusCode": 200,
"SslCheck": true,
"SslCertRemainingLifetimeCheck": 7
},
"Locations": [
{
"Id": "us-ca-sjc-azr"
},
{
"Id": "apac-sg-sin-azr"
},
{
"Id": "us-il-ch1-azr"
},
{
"Id": "us-va-ash-azr"
},
{
"Id": "emea-au-syd-edge"
}
]
},
"Tags": {
"hidden-link:/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>": "Resource"
}
}
注意
Web 测试区域(-location
)不同于地理位置(-Locations
),后者可以选择多个(请注意复数形式)。 -location
是指创建和托管 Web 测试的 Azure 区域,同时 -Locations
引用执行 Web 测试的地理位置或位置。 有关所有地理位置的完整列表,请参阅 Application Insights 可用性测试。
若要详细了解如何使用 REST API 创建和配置 Web 测试,请参阅 REST API 文档。
若要使用 Bicep 使用默认设置创建标准可用性测试,请将以下代码添加到模板,并将占位符<web-test-name>
、<azure-region-name>
、<subscription-id>
、<resource-group-name>
以及<application-insights-resource-name>
<url>
替换为特定值:
resource webTest 'microsoft.insights/webtests@2022-06-15' = {
name: '<web-test-name>'
location: '<azure-region-name>'
tags: {
'hidden-link:/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>': 'Resource'
}
properties: {
SyntheticMonitorId: '<web-test-name>'
Name: '<web-test-name>'
Enabled: true
Frequency: 300
Timeout: 120
Kind: 'standard'
RetryEnabled: true
Locations: [
{
Id: 'us-ca-sjc-azr'
}
{
Id: 'apac-sg-sin-azr'
}
{
Id: 'us-il-ch1-azr'
}
{
Id: 'us-va-ash-azr'
}
{
Id: 'emea-au-syd-edge'
}
]
Request: {
RequestUrl: '<url>'
HttpVerb: 'GET'
}
ValidationRules: {
ExpectedHttpStatusCode: 200
SSLCheck: true
SSLCertRemainingLifetimeCheck: 7
}
}
}
注意
Web 测试区域(location
)不同于可以选择多个区域的地理位置(Locations
)。 location
是指创建和托管 Web 测试的 Azure 区域,同时 Locations
引用执行 Web 测试的地理位置或位置。 有关所有地理位置的完整列表,请参阅 Application Insights 可用性测试。
有关使用 Bicep 创建可用性测试的详细信息,请参阅 Microsoft.Insights Webtests。
若要使用 ARM 模板创建具有默认设置的标准可用性测试,请将以下代码添加到模板中,并将占位符<web-test-name>
、<azure-region-name>
、<subscription-id>
、<resource-group-name>
以及<application-insights-resource-name>
<url>
替换为特定值:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "microsoft.insights/webtests",
"apiVersion": "2022-06-15",
"name": "<web-test-name>",
"location": "<azure-region-name>",
"tags": {
"hidden-link:/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.insights/components/<application-insights-resource-name>": "Resource"
},
"properties": {
"SyntheticMonitorId": "<web-test-name>",
"Name": "<web-test-name>",
"Enabled": true,
"Frequency": 300,
"Timeout": 120,
"Kind": "standard",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-ca-sjc-azr"
},
{
"Id": "apac-sg-sin-azr"
},
{
"Id": "us-il-ch1-azr"
},
{
"Id": "us-va-ash-azr"
},
{
"Id": "emea-au-syd-edge"
}
],
"Request": {
"RequestUrl": "<url>",
"HttpVerb": "GET"
},
"ValidationRules": {
"ExpectedHttpStatusCode": 200,
"SSLCheck": true,
"SSLCertRemainingLifetimeCheck": 7
}
}
}
]
}
注意
Web 测试区域(location
)不同于可以选择多个区域的地理位置(Locations
)。 location
是指创建和托管 Web 测试的 Azure 区域,同时 Locations
引用执行 Web 测试的地理位置或位置。 有关所有地理位置的完整列表,请参阅 Application Insights 可用性测试。
有关使用 ARM 模板创建可用性测试的详细信息,请参阅 Microsoft.Insights Webtests。
添加指标警报
小窍门
每个 Application Insights 资源都附带了现成可用的指标。 如果不同的组件向同一个 Application Insights 资源报告,那么基于这些指标发出警报可能没有意义。
若要自动创建指标警报,请参阅指标警报模板一文。
创建更多 Application Insights 资源
应该部署多少个 Application Insights 资源?
部署 Web 应用程序的下一个版本时,不希望将新版本和已发布的版本中的 Application Insights 遥测混合使用。
为了避免混淆,请使用单独的连接字符串将来自不同开发阶段的遥测数据发送到单独的 Application Insights 资源。
如果系统是 Azure 云服务的实例,有另一种设置单独连接字符串的方法。
何时使用单个 Application Insights 资源
将单个 Application Insights 资源用于:
- 为部署在一起的应用程序(通常由同一团队开发和管理)简化 DevOps/ITOps 管理。
- 将响应时间和故障率等关键性能指标集中在一个仪表板中(默认情况下)。 如有必要,按指标资源管理器中的角色名分段。
- 不需要在应用程序组件之间进行不同的 Azure 基于角色的访问控制管理。
- 当跨组件有相同的指标警报条件、连续导出和计费/配额管理都足够时。
- 一个 API 密钥可以平等地访问所有组件的数据且 10 个 API 密钥就能满足所有组件的需求。
- 可以对所有角色使用相同的智能检测和工作项集成设置时。
注意
如果要整合多个 Application Insights 资源,可以将现有的应用程序组件指向新的、合并的 Application Insights 资源。 存储在旧资源中的遥测数据不会传输到新资源。 仅当新资源中有了足够的遥测数据时才会删除旧资源,这样能保证业务连续性。
其他注意事项
若要激活门户体验,请添加自定义代码以将有意义的值分配给 Cloud_RoleName 属性。 如果没有这些值,门户功能将不起作用。
对于 Azure Service Fabric 应用程序和经典云服务,SDK 通过从 Azure 角色环境读取来自动配置服务。 对于不同类型的应用,通常需要显式地进行设置。
实时指标无法按角色名称拆分数据。
版本和发行版本跟踪
发布应用程序的新版本时,希望能够将遥测数据与不同的版本分开。 可以设置 应用程序版本 属性,以便筛选 搜索 和 指标资源管理器 结果。
可通过多种不同的方法设置“应用程序版本”属性。
选项 1: 直接设置版本
将行 telemetryClient.Context.Component.Version = typeof(MyProject.MyClass).Assembly.GetName().Version;
添加到应用程序的初始化代码。
若要确保以一致的方式设置所有 TelemetryClient
实例,请在遥测初始化表达式中将该行换行。
选项 2: 在 BuildInfo.config
中设置版本(仅限于 ASP.NET)
Application Insights Web 模块从 BuildLabel
节点中选取版本。 在项目中包含此文件,并记得在解决方案资源管理器中设置“始终复制”属性。
<?xml version="1.0" encoding="utf-8"?>
<DeploymentEvent xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/DeploymentEvent/2013/06">
<ProjectName>AppVersionExpt</ProjectName>
<Build type="MSBuild">
<MSBuild>
<BuildLabel kind="label">1.0.0.2</BuildLabel>
</MSBuild>
</Build>
</DeploymentEvent>
在 Microsoft 生成引擎中自动生成 BuildInfo.config
。 将以下行添加到 .csproj
文件:
<PropertyGroup>
<GenerateBuildInfoConfigFile>true</GenerateBuildInfoConfigFile>
<IncludeServerNameInBuildInfo>true</IncludeServerNameInBuildInfo>
</PropertyGroup>
此步骤会生成一个名为 yourProjectName 的文件。 发布过程会将此文件重命名为 BuildInfo.config
。
当使用 Visual Studio 生成时,生成标签包含一个占位符 (*AutoGen_...*)
。 使用 Microsoft Build 引擎构建时,占位符将填充正确的版本号。
若要让 Microsoft 生成引擎生成版本号,请在 1.0.*
中设置类似于 AssemblyReference.cs
的版本。
版本注释
如果使用 Azure DevOps,则可以在每次发布新版本时将批注标记添加到图表中。
自动化资源创建过程
可以通过将 Bicep 或 JSON 模板与 Azure 资源管理器配合使用来自动执行资源创建过程。 可以将多个资源打包在一起,以在一个部署中创建它们。 例如,可以使用可用性测试、指标警报和诊断设置创建 Application Insights 资源,以便将遥测数据发送到 Azure 存储帐户。
在 Azure 门户中生成模板
可以从现有资源生成模板。
仅 Application Insights
- 转到 Azure 门户中的 Application Insights 资源。
- 在左侧导航栏的“自动化”下打开“导出”模板。
- (可选):若要使用自己的参数,请取消选中 “包括”参数。
- 下载 模板文件或直接在 Azure 门户中 部署 它。
多个资源
- 转到你的 Application Insights 资源的资源组。
- 在“ 概述 ”窗格中,标记要包含在模板中的所有资源,然后选择顶部导航栏中的 “导出模板 ”。
- (可选):若要使用自己的参数,请取消选中 “包括”参数。
- 下载 模板文件或直接在 Azure 门户中 部署 它。
从头开始创建模板
若要了解如何从头开始创建 ARM 模板,请访问 ARM 模板文档 ,其中包含用于 创建模板、 添加资源、 添加参数等的教程。
可以在我们的 Azure 资源参考文档的“参考”“监视器”“见解”节点下找到 >、可用性测试、>、诊断设置和其他资源的可用属性。
常见问题
本部分提供常见问题的解答。
如何将 Application Insights 资源移动到新区域?
在区域之间传输现有的 Application Insights 资源不受支持,并且你无法将历史数据迁移到新区域。 解决方法包括:
- 在所需区域中创建新的 Application Insights 资源。
- 在新资源中重新创建原始资源中的任何唯一自定义项。
- 使用新区域资源的连接字符串更新应用程序。
- 进行测试以确保新的 Application Insights 资源一切都按预期运行。
- 决定保留还是删除原始 Application Insights 资源。 删除经典资源意味着丢失所有历史数据。 如果资源基于工作区,则数据将保留在 Log Analytics 中,从而使用户可以访问历史数据,直到保留期到期。
通常需要在新区域中为资源手动重新创建或更新的唯一自定义项包括但不限于:
- 重新创建自定义仪表板和工作簿。
- 重新创建或更新任何自定义日志/指标警报的范围。
- 重新创建可用性警报。
- 重新创建用户访问新资源所需的任何 Azure 基于角色的访问控制自定义设置。
- 复制那些涉及引入采样、数据保留、每日上限和自定义指标启用的设置。 可通过“使用情况和预估成本”窗格控制这些设置。
- 依赖 API 密钥(例如版本注释和实时指标安全控制通道)的任何集成。 你需要生成新的 API 密钥并更新关联的集成。
- 必须重新配置经典资源中的连续导出。
- 必须重新配置基于工作区资源中的诊断设置。
能否在 Azure 资源管理器部署中使用 providers('Microsoft.Insights', 'components').apiVersions[0]?
不建议使用此方法来填充 API 版本。 最新版本可以表示预览版本,该版本可能包含重大更改。 即使使用较新的非预览版本,API 版本也并不总是与现有模板向后兼容。 在某些情况下,API 版本可能并不适用于所有订阅。
后续步骤