4 min read

Getting started with AzureArcConnectedAgentManagement PowerShell Module

Getting started with AzureArcConnectedAgentManagement PowerShell Module
Managing the Azure Arc Connected Agent using PowerShell

Introduction

Last week I posted a blog about how to manage Azure Arc Connected Agent through the Azcmagent.exe utility. Azcmagent.exe allows you to manage the agent settings, view agent connection status, and troubleshoot if something is not working as excepted.

To simplify our day-to-day administration around Azure Arc, I wrote a PowerShell module for the Azcmagent.exe utility. These commands give us a much better user experience.

AzureArcConnectedAgentManagement PowerShell Module is published on the PowerShell Gallery and has 15 commands.

• Clear-AzureArcNodeConfiguration
• Connect-AzureArcNode
• Disconnect-AzureArcNode
• Get-AzureArcNodeAgentConfigurationFileContent
• Get-AzureArcNodeAgentInformation
• Get-AzureArcNodeAgentInstalledExtensions
• Get-AzureArcNodeAgentLocalConfigurationFileContent
• Get-AzureArcNodeConfiguration
• Get-AzureArcNodeServiceStatus
• Install-AzureArcAgent
• Restart-AzureArcNodeService
• Save-AzureArcNodeLogs
• Set-AzureArcNodeConfiguration
• Test-AzureArcNodeConnection
• Test-AzureArcNodeNetworkConnectivity

Just a reminder! It is my first release, so there may be bugs.

Microsoft has its own PowerShell module as well, but mostly for onboarding activities rather than managing the local agent settings etc

How to install AzureArcConnectedAgentManagement Module

  1. Open PowerShell as an administrator and run the following command:
    a. Install-Module -Name AzureArcConnectedAgentManagement
  2. After the installation, print out all the commands using the following command
    a. Get-Command -Module AzureArcConnectedAgentManagement

AzureArcConnectedAgentManagement Module commands

Clear-AzureArcNodeConfiguration

Allows clearing Azure Arc agent configuration by setting name.

Example

Clear-AzureArcNodeConfiguration -ConfigurationName proxy.bypass -OutPutType JSON 

Connect-AzureArcNode

Connect the local machine to Azure Arc service. You can choose in three different ways:

  • Access Token
  • Service Principal
  • Device Login
Connect-AzureArcNode

Disconnect-AzureArcNode

Allows you to disconnect connected nodes from Azure Arc service.

Disconnect-AzureArcNode

Get-AzureArcNodeAgentConfigurationFileContent

Reads the Azure Arc Connected Agent configuration file from C:\ProgramData\AzureConnectedMachineAgent\Config\agentconfig.json file

Get-AzureArcNodeAgentConfigurationFileContent

Get-AzureArcNodeAgentInformation

Provides information about Azure Arc Connected Agents. You can specify the output as JSON or RAW.

Get-AzureArcNodeAgentInformation

Example

Get-AzureArcNodeAgentInformation -OutPutType JSON
Get-AzureArcNodeAgentInformation -OutPutType RAW

Get-AzureArcNodeAgentInstalledExtensions

Reads installed extension from the C:\ProgramData\GuestConfig\extension_logs folder.

Get-AzureArcNodeAgentInstalledExtensions

Example

Get-AzureArcNodeAgentInstalledExtensions |
    Format-Table -AutoSize -Property ExtensionName, ExtensionState, ExtensionVersion 

Get-AzureArcNodeAgentLocalConfigurationFileContent

The command reads the C:\ProgramData\AzureConnectedMachineAgent\Config\localconfig.json file.

Get-AzureArcNodeAgentLocalConfigurationFileContent

Example

Get-AzureArcNodeAgentLocalConfigurationFileContent

Get-AzureArcNodeConfiguration

Allows you to read Azure Arc Connected Agent configured settings.

Get-AzureArcNodeConfiguration

Example

Get-AzureArcNodeConfiguration -ConfigurationName extensions.allowlist -OutPutType JSON
Get-AzureArcNodeConfiguration -ConfigurationName extensions.allowlist -OutPutType RAW

Get-AzureArcNodeServiceStatus

Prints out the Azure Hybrid Instance Metadata Service status.

Get-AzureArcNodeServiceStatus

Example

Get-AzureArcNodeServiceStatus

Install-AzureArcAgent

Downloads and installs Azure Arc Connected Agent.

Restart-AzureArcNodeService

Restarts the Azure Hybrid Instance Metadata Service

Save-AzureArcNodeLogs

Allows you to save Azure Arc Agent logs to your desktop for troubleshooting.

Save-AzureArcNodeLogs

Set-AzureArcNodeConfiguration

Allows configuring different Azure Arc Agent settings, such as proxy etc.

Example

Set-AzureArcNodeConfiguration -ConfigurationName proxy.url -ConfigurationValue "http://myproxy:443" -OutPutType JSON

Test-AzureArcNodeConnection

Prints out current agent status, if the agent is OK or not.

Test-AzureArcNodeConnection

Test-AzureArcNodeNetworkConnectivity

Allows you to verify if the connection from the local machine is OK and meets all the requirements.

Test-AzureArcNodeNetworkConnectivity

Example

Test-AzureArcNodeNetworkConnectivity -OutPutType JSON -Location "West Europe"

Summary

As you now see, it will be much easier to manage the local Azure Arc agent using these PowerShell commands. If you have any feedback, please add a comment to this post, email me or on GitHub.

GitHub - Kaidja/AzureArcConnectedAgentManagement: PowerShell module for Azure Arc Connected Agent.
PowerShell module for Azure Arc Connected Agent. Contribute to Kaidja/AzureArcConnectedAgentManagement development by creating an account on GitHub.

Need assistance implementing Azure Arc, let me know.