Monitoring Azure Stack Update Status

Microsoft has good documentation surrounding the Azure Stack update process, so my goal is not to repeat that content but to add some color by sharing some of the commands that I use. To do this I’ll share the example script from Microsoft and then my variation of the script.

Creating the Privileged Endpoint Session

Purpose:

This establishes the Privileged Endpoint session. You could accomplish this using Enter-PSSession, but doing it this way allows you to stay in the context of your workstation and gives you access to local resources like drives (for output files) and installed modules (for additional output processing). This is an important command to know and should be in the toolbelt of any Azure Stack Cloud Operator.

Microsoft Example:

$cred = Get-Credential

$pepSession = New-PSSession -ComputerName <Prefix>-ercs01 -Credential $cred -ConfigurationName PrivilegedEndpoint

Explanation:

The Microsoft approach of storing the credential in a variable is useful if you need to use the credential again, but in this scenario it’s not necessary. The modified command below consolidates the same process into a single line and still doesn’t expose the PEP password in the script. When executing the command the login prompt will appear with the username pre-populated – simply enter the password and login.

My Example:

$pepSession = New-PSSession -ComputerName <ERCS Name or IP> -ConfigurationName PrivilegedEndpoint -Credential <Domain>CloudAdmin

Getting the High-Level Status of the Current Update Process

Purpose:

This one is great to do a quick check of the update process, especially because it replaces the need to click through the admin portal to bring up the Update blade.

Microsoft Example:

$statusString = Invoke-Command -Session $pepSession -ScriptBlock { Get-AzureStackUpdateStatus -StatusOnly }

$statusString.Value

Explanation:

Here we have a script that creates a variable and then uses the variable to access a property. By wrapping the first command in parentheses I can access the property on the same line. This is a useful trick in PowerShell for consolidating commands when using the console. It also allows me to see the most recent status by running the command without having to refresh the variable.

My Example:

(Invoke-Command -Session $pepSession -ScriptBlock {Get-AzureStackUpdateStatus -StatusOnly}).Value

Getting the Full Update Status with Details

Purpose:

This is the command to use if you need more detail regarding the current steps in the update process. It uses the Get-AzureStackUpdateStatus cmdlet, which returns the full update output as XML, but filters out everything except the currently executing steps. I find this helpful for getting an understanding of the update process, but it is invaluable when you are trying to work through a failure. This information is also available in the Admin Portal through the Update Status blade, but I find this method a lot easier than downloading and scanning through an XML document.

Microsoft Example:

[xml]$updateStatus = Invoke-Command -Session $pepSession -ScriptBlock { Get-AzureStackUpdateStatus }

$updateStatus.SelectNodes(“//Step[@Status=’InProgress’]”)

Explanation:

Similar to the previous command we are declaring a variable and then using that variable to access a method. By using the same principal as before we can wrap the first step in parentheses, but in this case it also includes the cast to XML. This is needed to access the SelectNodes() method in the second step. You can also change the “InProgress” to “Error” to see tasks that have failed.

My Example:

([xml](Invoke-Command -Session $pepSession -ScriptBlock {Get-AzureStackUpdateStatus})).SelectNodes(“//Step[@Status=’InProgress’]”)

Getting the Verbose Azure Stack Update Log

Purpose:

When things have gone wrong during an update and you’re trying to understand why, that’s when you break out this command. It will output the verbose log data from the latest update session to a text file for review. This will include Informational (“VerboseMessage”), Warning (“WarningMessage”), and Exception (“ErrorMessage”) records.

Microsoft Example:

  1. None.

Explanation:

Since there is currently no example in the Microsoft documentation, we’ll jump straight to how I run the command. This will output the verbose update log to a text file in a specified location. It’s pretty straightforward, but I’ve added the date and time to the output file name because I want to allow for this command to be run multiple times during the course of an update cycle.

My Example:

Invoke-Command -Session $pepSession -ScriptBlock {Get-AzureStackUpdateVerboseLog} | Out-File -FilePath <FileName with Path>_$(Get-Date -Format “yyyyMMdd_HHmmss”).txt

Most of the changes that are shown here boil down to one important aspect of PowerShell…the way you execute on the console is different than the way you execute in a script. When scripting I have 2 primary goals:

  • Perform a repeatable activity
  • Make the script easy to read, understand, and by extension…maintain

When I’m executing commands from the console the goal is generally the shortest path to the result I’m looking for. I will avoid storing a value in a variable unless I need to use it more than once. I am also more likely to use aliases for cmdlets because I’m not looking to save my work, so readability is not as important.

I hope that you find this information useful and look forward to hearing your feedback.

Related:

Leave a Reply