-2

We have a solution running on some 140vms in an Azure VMSS.

How do I enable any of these memory dump options through the ARM Template?

Barring that, how could I enable it with a PowerShell script?

Enable Crash Dump

EtherDragon
  • 172
  • 7

2 Answers2

1

Yes, you can add the information to your ARM Template using DSC or CSE but the ksy is what in the script. Below is sample information that should be in the script, enableDump.ps1

# Setup the Guest OS to collect a kernel dump on an OS crash event
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -name CrashDumpEnabled -Type DWord -force -Value 2
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -name DumpFile -Type ExpandString -force -Value "%SystemRoot%\MEMORY.DMP"
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -name NMICrashDump -Type DWord -force -Value 1

Reference to values in script; https://support.microsoft.com/en-us/help/254649/overview-of-memory-dump-file-options-for-windows

CustomScript setting in Arm Template can be as simple as;

  {
    "type": "extensions",
    "name": "CustomScriptExtension",
    "apiVersion": "2017-03-30",
    "location": "[parameters('location')]",
    "dependsOn": [
      "[variables('vmName')]"
    ],
    "properties": {
      "publisher": "Microsoft.Compute",
      "type": "CustomScriptExtension",
      "typeHandlerVersion": "1.8",
      "autoUpgradeMinorVersion": true,
      "settings": {
        "fileUris": [
          "https://xxxxxxx.blob.core.windows.net/buildServer1/enableDump.ps1"
        ],
        "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File ./EnableCrashDump.ps1"
      }
    }
  }

Hope this helps.

EtherDragon
  • 172
  • 7
Hannel
  • 651
  • 4
  • 9
  • That's fantastic, I'll give it a try next week and let you know how it goes! – EtherDragon Dec 02 '18 at 00:21
  • I got the arm template update and the PS1 available to the template. It seems to run, but I'm getting a failure during deploy with the ever so helpful message "Finished executing command" But it comes as an error marking the deploy as failed. – EtherDragon Dec 05 '18 at 23:37
  • 1
    Test it on a VM, so it's easier to look at the handler and execution log for extension. You might be missing permission on container holding script. – Hannel Dec 06 '18 at 00:45
  • 1
    I have an edit to this answer under review, but to make the command work, use "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File ./EnableCrashDump.ps1" instead of what's there. – EtherDragon Dec 21 '18 at 15:36
0

You cant do that with ARM Template, you can, however, use script or powershell dsc extension (as part of the arm template) to configure that. examples of those extensions:

{
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "name": "[concat(variables('vmName'),'/installcustomscript')]",
    "apiVersion": "2015-05-01-preview",
    "location": "[parameters('location')]",
    "properties": {
        "publisher": "Microsoft.Azure.Extensions",
        "type": "CustomScript",
        "typeHandlerVersion": "2.0",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "fileUris": [
                "[concat(parameters('_artifactsLocation'), '/scripts/hello.sh')]"
            ],
            "commandToExecute": "[parameters('commandToExecute')]"
        }
    }
},
{
    "apiVersion": "2015-05-01-preview",
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "name": "[concat(parameters('vmName'),'/enabledsc')]",
    "location": "[parameters('location')]",
    "properties": {
        "publisher": "Microsoft.Powershell",
        "type": "DSC",
        "typeHandlerVersion": "2.0",
        "settings": {
            "Mode": "[parameters('mode')]",
            "FileUri": "[parameters('fileUri')]"
        },
        "protectedSettings": {
            "StorageAccountName": "[parameters('storageAccountName')]",
            "StorageAccountKey": "[parameters('storageAccountKey')]",
            "RegistrationUrl": "[parameters('registrationUrl')]",
            "RegistrationKey": "[parameters('registrationKey')]"
        }
    }
}

Reading:
https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-overview

4c74356b41
  • 628
  • 5
  • 10