Introducing Get-AzureVMDscExtensionStatus cmdlet for Azure Powershell DSC Extension
ast August we introduced PowerShell Desired State Configuration (DSC) Extension for Azure VMs.
Through cmdlets released in the Azure PowerShell SDK, you can upload and apply a PowerShell DSC configuration to an Azure VM.
Now, we are introducing a new cmdlet
This new cmdlet retrieves the status of the DSC Extension in all the VMs deployed in a cloud service or a particular VM.
It allows you to monitor the progress of the extension and the current status along with the detailed configuration logs.
Once you have updated the DSC Extension to version 1.7 and the Azure Powershell to 0.8.14, you can use the
Get-AzureVMDscExtensionStatus cmdlet to get the extension status.
How to use the cmdlet
There are two ways you can use this cmdlet :
- By specifying the service name.
Service name is a mandatory parameter for this parameter set.
A cloud service can have one or more virtual machines deployed.
When the service name is specified as the parameter, the cmdlet brings back the status for all the VM(s) deployed in that specific service.
When the service name and name both are specified as parameters, the cmdlet returns the status for the VM specified provided there exists a VM with that name in the given cloud service.
- By specifying a VM object.
You can specify a VM object (as returned by Get-AzureVM cmdlet) as a parameter to this cmdlet. You can pass the VM object through the pipeline.
‘example-service’ is the name of the cloud service and ‘example-0’ is the name of the virtual machine deployed in ‘example-service’.
$status object returned by the cmdlet, contains a status (Success, Transitioning, Error, Warning),
Status Code and Status Message from the
DSCExtensionStatus.psm1 file (in the bin folder of the DSC Extension Handler install directory) for the DSC Extension handler.
It also returns a timestamp and configuration logs.
Now let us push a sample configuration to a VM and see how the cmdlet retrieves the status and the configuration logs.
The Configuration hasn’t finish yet. When we run
Get-AzureVMDscExtensionStatus again after some time we see that configuration succeed.
The cmdlet retrieves new events captured by the extension handler as they occur on the machine providing status updates and configuration logs.
There is a delay of a few minutes introduced by the Azure status caching layer.
The timestamp field helps differentiate between the old and the new status.
In the event of an error or warning while running a configuration, the appropriate status message will appear, along with a detailed log containing the error or warning stream.
As you can see, the configuration that we just pushed to the Extension Handler completed successfully.
Detailed logs will still persist on the VM under
Get-AzureVMDscExtensionStatus gives you ability to monitor the result of an ongoing configuration without logging onto the machine.