Hi,
I manually added App Insights to a VM via the portal and then used Azure Resource Explorer to see the resulting resource definition for the VM. I'm using classicCompute rather than the v2 stuff because I'm in a region that isn't supported for v2 yet.
I have the following json in my template:
{"type": "Microsoft.ClassicCompute/virtualMachines","name": "[parameters('vmName')]","apiVersion": "2014-06-01","location": "[parameters('location')]","properties": {"domainName": {"id": "[concat(resourceGroup().id, '/providers/Microsoft.ClassicCompute/domainNames/', parameters('vmName'))]" },"networkProfile": {"virtualNetwork": {"id": "[concat(resourceGroup().id, '/providers/Microsoft.ClassicNetwork/virtualNetworks/', parameters('vnetName'))]","subnetNames": ["Subnet-1" ] },"inputEndpoints": [ {"enableDirectServerReturn": "False","endpointName": "Remote Desktop","privatePort": 3389,"publicPort": 53316,"protocol": "tcp" }, {"enableDirectServerReturn": "False","endpointName": "Powershell","privatePort": 5986,"publicPort": 5986,"protocol": "tcp" }, {"enableDirectServerReturn": "False","endpointName": "HTTPS","privatePort": 443,"publicPort": 443,"protocol": "tcp" }, {"enableDirectServerReturn": "False","endpointName": "Octopus Tentacle","privatePort": 10933,"publicPort": 10933,"protocol": "tcp" }, ] },"hardwareProfile": {"size": "[parameters('vmSize')]","platformGuestAgent": "true" },"operatingSystemProfile": {"computerName": "[parameters('vmName')]","adminUserName": "[parameters('vmAdminUserName')]","adminPassword": "[parameters('vmAdminPassword')]","windowsOperatingSystemProfile": {"winRMListeners": [ {"protocol": "Https" } ] } },"storageProfile": {"operatingSystemDisk": {"diskName": "[concat(parameters('vmName'), '-osdisk')]","vhdUri": "[concat(reference(concat('Microsoft.ClassicStorage/storageAccounts/', parameters('vmStorageAccountName'))).endpoints[0], 'vhds/', parameters('vmName'), '-osdisk.vhd')]","caching": "ReadWrite","sourceImageName": "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201504.01-en.us-127GB.vhd" } },"extensions": [ {"extension": "DSC","publisher": "Microsoft.Powershell","version": "1.*","parameters": {"public": {"SasToken": "","ModulesUrl": "http://appinsightsstatusmonitor.blob.core.windows.net/statusmonitor/ApplicationInsights.ps1.zip","ConfigurationFunction": "ApplicationInsights.ps1\\ApplicationInsightsConfig","Properties": {"InstrumentationKey": "[reference(concat('Microsoft.Insights/components/', parameters('vmName'))).InstrumentationKey]" } } } } ] },"dependsOn": ["[concat('Microsoft.ClassicCompute/domainNames/', parameters('vmName'))]","[concat('Microsoft.ClassicNetwork/virtualNetworks/', parameters('vnetName'))]","[concat('Microsoft.Insights/components/', parameters('vmName'))]" ] }, {"apiVersion": "2014-08-01","name": "[parameters('vmName')]","type": "Microsoft.Insights/components","location": "Central US","tags": {"displayName": "insightsComponents" },"properties": {"Application_Type": "web","ApplicationId": "[parameters('vmName')]" } }
The script worked fine before adding the extension. After adding the extension I get the following error:
Resource Microsoft.ClassicCompute/virtualMachines '{vmname}' failed with message 'Unable to create virtual machine '{vmname}': 'Invalid update to extension reference for
role: {vmname} and reference: Microsoft.Powershell.DSC.'.'
Does anyone have any ideas on what's wrong? I tried with the InstrumentationKey being a static value as well as a reference to the other resource to no avail.
Thanks!