関連付け用の ARM テンプレートはターゲット オブジェクトごとに異なります。 さまざまな種類のオブジェクトに使用できるテンプレートを次に示します。
Azure VM
次のサンプルによって、Azure 仮想マシンとデータ収集ルールとの間に関連付けが作成されます。
Bicep テンプレート ファイル
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this virtual machine.'
dataCollectionRuleId: dataCollectionRuleId
}
}
ARM テンプレート ファイル
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "The name of the virtual machine."
}
},
"associationName": {
"type": "string",
"metadata": {
"description": "The name of the association."
}
},
"dataCollectionRuleId": {
"type": "string",
"metadata": {
"description": "The resource ID of the data collection rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-09-01-preview",
"scope": "[format('Microsoft.Compute/virtualMachines/{0}', parameters('vmName'))]",
"name": "[parameters('associationName')]",
"properties": {
"description": "Association of data collection rule. Deleting this association will break the data collection for this virtual machine.",
"dataCollectionRuleId": "[parameters('dataCollectionRuleId')]"
}
}
]
}
@description('The name of the virtual machine.')
param vmName string
@description('The name of the association.')
param associationName string
@description('The resource ID of the data collection rule.')
param dataCollectionRuleId string
resource vm 'Microsoft.HybridCompute/machines@2021-11-01' existing = {
name: vmName
}
resource association 'Microsoft.Insights/dataCollectionRuleAssociations@2021-09-01-preview' = {
name: associationName
scope: vm
properties: {
description: 'Association of data collection rule. Deleting this association will break the data collection for this Arc server.'
dataCollectionRuleId: dataCollectionRuleId
}
}
ARM テンプレート ファイル
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "The name of the virtual machine."
}
},
"associationName": {
"type": "string",
"metadata": {
"description": "The name of the association."
}
},
"dataCollectionRuleId": {
"type": "string",
"metadata": {
"description": "The resource ID of the data collection rule."
}
}
},
"resources": [
{
"type": "Microsoft.Insights/dataCollectionRuleAssociations",
"apiVersion": "2021-09-01-preview",
"scope": "[format('Microsoft.HybridCompute/machines/{0}', parameters('vmName'))]",
"name": "[parameters('associationName')]",
"properties": {
"description": "Association of data collection rule. Deleting this association will break the data collection for this Arc server.",
"dataCollectionRuleId": "[parameters('dataCollectionRuleId')]"
}
}
]
}