Microsoft Azure: Send Diagnostic Monitoring Data from a Windows IaaS VM to an Event Hub, Part 2
In Part 1 I went into the details of configuring an IaaS VM with a trivial configuration file using PowerShell. Then I added a few lines to start the flow of a small set of messages. In this post, I'll show how to do the same thing using the Azure CLI.
In the PowerShell scenario, both the public and private settings are combined into one file before sending to the VM. With the CLI, the two are separated into separate files. Here's what should go into a file named something like publicConfig.json:
[code lang="js"]
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": 4096,
"sinks": "HotPath"
},
"SinksConfig": {
"Sink": [
{
"name": "HotPath",
"EventHub": {
"Url": "https://myEHNamespace.servicebus.windows.net/myEHHubName",
"SharedAccessKeyName": "RootManageSharedAccessKey"
}
}
]
}
},
"storageAccount": "mystorageaccountname"
}
And into a file named something like privateConfig.json, put the rest of the lines:
[js]
{
"storageAccountName": "mystorageaccountname",
"storageAccountKey": "NotReallyMyStorageAccountKey==",
"storageAccountEndPoint": "https://core.windows.net/",
"EventHub": {
"Url": "https://myEHNamespace.servicebus.windows.net/myEHHubName",
"SharedAccessKeyName": "RootManageSharedAccessKey",
"SharedAccessKey": "Jf9JhNotReallyMyKeyCC/ZCSl6h5pq4lnBDtsUoXYZ="
}
}
[/js]
The command to load the configuration into the VM is going to be something like this:
[code lang="text"]
az vm diagnostics set -g YOURRESOURCEGROUP --vm-name YOURVM --settings @/pathto/publicConfig.json --protected-settings @/pathto/privateConfig.json
You can use the Azure CLI in a variety of ways: a Linux server, a Mac terminal, Bash on Windows, Azure Cloud Shell, and so on.
Cheers!