<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bicep on The DevOps Quest</title>
    <link>https://thedevops.quest/tags/bicep/</link>
    <description>Recent content in Bicep on The DevOps Quest</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-gb</language>
    <copyright>© Adam</copyright>
    <lastBuildDate>Fri, 06 Oct 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://thedevops.quest/tags/bicep/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Virtual Machines Insights</title>
      <link>https://thedevops.quest/posts/vminsights/</link>
      <pubDate>Fri, 06 Oct 2023 00:00:00 +0000</pubDate>
      
      <guid>https://thedevops.quest/posts/vminsights/</guid>
      <description>&lt;p&gt;I recently worked on implementing VM Insights into Virtual Machines. However the latest templates provided by Microsoft were still written in ARM and generally a little complex. I have converted them to Bicep and edited them a little bit.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;param location string = resourceGroup().location

param virtualMachineName string
param logAnalyticsNamespaceName string

resource virtualMachine &amp;#39;Microsoft.Compute/virtualMachines@2023-07-01&amp;#39; existing = {
  name: virtualMachineName
}

resource logAnalyticsWorkspace &amp;#39;Microsoft.OperationalInsights/workspaces@2022-10-01&amp;#39; existing = {
  name: logAnalyticsNamespaceName
}

resource MSVMI_DCR &amp;#39;Microsoft.Insights/dataCollectionRules@2022-06-01&amp;#39; = {
  name: &amp;#39;MSVMI-${virtualMachine.name}&amp;#39;
  location: location
  properties: {
    description: &amp;#39;Standard data collection rule for VM Insights.&amp;#39;
    dataSources: {
      performanceCounters: [
        {
          name: &amp;#39;VMInsightsPerfCounters&amp;#39;
          streams: [
            &amp;#39;Microsoft-InsightsMetrics&amp;#39;
          ]
          samplingFrequencyInSeconds: 60
          counterSpecifiers: [
            &amp;#39;\\VmInsights\\DetailedMetrics&amp;#39;
          ]
        }
      ]
      extensions: [
        {
          streams: [
            &amp;#39;Microsoft-ServiceMap&amp;#39;
          ]
          extensionName: &amp;#39;DependencyAgent&amp;#39;
          name: &amp;#39;DependencyAgentDataSource&amp;#39;
        }
      ]
    }
    destinations: {
      logAnalytics: [
        {
          workspaceResourceId: logAnalyticsWorkspace.id
          name: &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        }
      ]
    }
    dataFlows: [
      {
        streams: [
          &amp;#39;Microsoft-InsightsMetrics&amp;#39;
        ]
        destinations: [
          &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        ]
      }
      {
        streams: [
          &amp;#39;Microsoft-ServiceMap&amp;#39;
        ]
        destinations: [
          &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        ]
      }
    ]
  }
}

resource Vm_DaExtension &amp;#39;Microsoft.Compute/virtualMachines/extensions@2023-07-01&amp;#39; = {
  parent: virtualMachine
  name: &amp;#39;DependencyAgentWindows&amp;#39;
  location: location
  properties: {
    publisher: &amp;#39;Microsoft.Azure.Monitoring.DependencyAgent&amp;#39;
    type: &amp;#39;DependencyAgentWindows&amp;#39;
    typeHandlerVersion: &amp;#39;9.5&amp;#39;
    autoUpgradeMinorVersion: true
    settings: {
      enableAMA: &amp;#39;true&amp;#39;
    }
  }
}

resource Vm_AmaExtension &amp;#39;Microsoft.Compute/virtualMachines/extensions@2023-07-01&amp;#39; = {
  parent: virtualMachine
  name: &amp;#39;AzureMonitorWindowsAgent&amp;#39;
  location: location
  properties: {
    publisher: &amp;#39;Microsoft.Azure.Monitor&amp;#39;
    type: &amp;#39;AzureMonitorWindowsAgent&amp;#39;
    typeHandlerVersion: &amp;#39;1.0&amp;#39;
    autoUpgradeMinorVersion: true
  }
}

resource Vm_Microsoft_Insights_VMInsights_Dcr_Association &amp;#39;Microsoft.Insights/dataCollectionRuleAssociations@2022-06-01&amp;#39; = {
  name: &amp;#39;${virtualMachine.name}-VMInsights-Dcr-Association&amp;#39;
  scope: virtualMachine
  properties: {
    description: &amp;#39;Association of data collection rule for VM Insights.&amp;#39;
    dataCollectionRuleId: MSVMI_DCR.id
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Health&lt;/strong&gt; ❤️ ❤️ ❤️ ❤️ ❤️&lt;/p&gt;</description>
      <content>&lt;p&gt;I recently worked on implementing VM Insights into Virtual Machines. However the latest templates provided by Microsoft were still written in ARM and generally a little complex. I have converted them to Bicep and edited them a little bit.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;param location string = resourceGroup().location

param virtualMachineName string
param logAnalyticsNamespaceName string

resource virtualMachine &amp;#39;Microsoft.Compute/virtualMachines@2023-07-01&amp;#39; existing = {
  name: virtualMachineName
}

resource logAnalyticsWorkspace &amp;#39;Microsoft.OperationalInsights/workspaces@2022-10-01&amp;#39; existing = {
  name: logAnalyticsNamespaceName
}

resource MSVMI_DCR &amp;#39;Microsoft.Insights/dataCollectionRules@2022-06-01&amp;#39; = {
  name: &amp;#39;MSVMI-${virtualMachine.name}&amp;#39;
  location: location
  properties: {
    description: &amp;#39;Standard data collection rule for VM Insights.&amp;#39;
    dataSources: {
      performanceCounters: [
        {
          name: &amp;#39;VMInsightsPerfCounters&amp;#39;
          streams: [
            &amp;#39;Microsoft-InsightsMetrics&amp;#39;
          ]
          samplingFrequencyInSeconds: 60
          counterSpecifiers: [
            &amp;#39;\\VmInsights\\DetailedMetrics&amp;#39;
          ]
        }
      ]
      extensions: [
        {
          streams: [
            &amp;#39;Microsoft-ServiceMap&amp;#39;
          ]
          extensionName: &amp;#39;DependencyAgent&amp;#39;
          name: &amp;#39;DependencyAgentDataSource&amp;#39;
        }
      ]
    }
    destinations: {
      logAnalytics: [
        {
          workspaceResourceId: logAnalyticsWorkspace.id
          name: &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        }
      ]
    }
    dataFlows: [
      {
        streams: [
          &amp;#39;Microsoft-InsightsMetrics&amp;#39;
        ]
        destinations: [
          &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        ]
      }
      {
        streams: [
          &amp;#39;Microsoft-ServiceMap&amp;#39;
        ]
        destinations: [
          &amp;#39;VMInsightsPerf-Logs-Dest&amp;#39;
        ]
      }
    ]
  }
}

resource Vm_DaExtension &amp;#39;Microsoft.Compute/virtualMachines/extensions@2023-07-01&amp;#39; = {
  parent: virtualMachine
  name: &amp;#39;DependencyAgentWindows&amp;#39;
  location: location
  properties: {
    publisher: &amp;#39;Microsoft.Azure.Monitoring.DependencyAgent&amp;#39;
    type: &amp;#39;DependencyAgentWindows&amp;#39;
    typeHandlerVersion: &amp;#39;9.5&amp;#39;
    autoUpgradeMinorVersion: true
    settings: {
      enableAMA: &amp;#39;true&amp;#39;
    }
  }
}

resource Vm_AmaExtension &amp;#39;Microsoft.Compute/virtualMachines/extensions@2023-07-01&amp;#39; = {
  parent: virtualMachine
  name: &amp;#39;AzureMonitorWindowsAgent&amp;#39;
  location: location
  properties: {
    publisher: &amp;#39;Microsoft.Azure.Monitor&amp;#39;
    type: &amp;#39;AzureMonitorWindowsAgent&amp;#39;
    typeHandlerVersion: &amp;#39;1.0&amp;#39;
    autoUpgradeMinorVersion: true
  }
}

resource Vm_Microsoft_Insights_VMInsights_Dcr_Association &amp;#39;Microsoft.Insights/dataCollectionRuleAssociations@2022-06-01&amp;#39; = {
  name: &amp;#39;${virtualMachine.name}-VMInsights-Dcr-Association&amp;#39;
  scope: virtualMachine
  properties: {
    description: &amp;#39;Association of data collection rule for VM Insights.&amp;#39;
    dataCollectionRuleId: MSVMI_DCR.id
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Health&lt;/strong&gt; ❤️ ❤️ ❤️ ❤️ ❤️&lt;/p&gt;
&lt;p&gt;See you soon 🗡️&lt;/p&gt;
</content>
    </item>
    
  </channel>
</rss>
