PowerShell by Patrik

Extracting a Specific JSON Section in Azure RunCommand

Reduce Console Noise: Extract Only What You Need

When using Azure RunCommand on a virtual machine, the output console is limited. If you print an entire configuration file, large parts may be cut off. This makes troubleshooting difficult, especially when you only need a small section such as the environment node.

Instead of displaying the full file, you can extract just the required part. This keeps the output small, clear, and readable. It also helps you work safely with large configuration files in production systems.

In this guide, you will see two practical approaches:

  1. A structured JSON method (best when the file is valid JSON)
  2. A multiline Regex method (useful when the file is not valid JSON)

Both approaches are written for PowerShell and work well inside Azure RunCommand. The examples use small sample files to stay focused on the solution itself.

Each section explains one method clearly so you can choose the right technique for your scenario.

azure
powershell
json
automation
troubleshooting

Comments