Kaido Jarvemets - Logo

Maximize Your Cloud Reach: Connect On-Premises Machines to Azure Arc with PowerShell

Introduction

There are several ways to connect machines to Azure Arc, including using the Microsoft Monitoring Agent, as I discussed in a previous blog post. However, not all customers use Azure Update Management, so alternative methods for onboarding Azure Arc agents may be needed. These alternative methods can help ensure that customers can connect their machines to Azure Arc, regardless of whether they use Azure Update Management.

You can read more about how to do the onboarding through MMA and Azure Update Management.

Unleash the Power of Azure Arc for Servers

Experience the Future of Hybrid-Cloud Management: Connect with us to learn how Azure Arc can revolutionize your infrastructure and streamline operations.
Call to Action

In this blog post, I will show how to use Az.ConnectedMachine PowerShell module to onboard machines to Azure Arc. The Az.ConnectedMachine module is an official module from Microsoft that provides a range of commands for managing and monitoring Azure Arc-connected machines. The current version (0.6.0) of the Az.ConnectedMachine module includes 22 different commands, which can be used to perform a wide variety of tasks related to Azure Arc-connected machines.

Az.ConnectedMachine module commands:

				
					Connect-AzConnectedMachine
Get-AzConnectedExtensionMetadata
Get-AzConnectedMachine
Get-AzConnectedMachineExtension
Get-AzConnectedMachineRunCommand
Get-AzConnectedPrivateLinkScope
Install-AzConnectedMachinePatch
Invoke-AzConnectedAssessMachinePatch
New-AzConnectedMachineExtension
New-AzConnectedMachineRunCommand
New-AzConnectedPrivateLinkScope
Remove-AzConnectedMachine
Remove-AzConnectedMachineExtension
Remove-AzConnectedMachineRunCommand
Remove-AzConnectedPrivateLinkScope
Set-AzConnectedMachineExtension
Set-AzConnectedPrivateLinkScope
Update-AzConnectedExtension
Update-AzConnectedMachine
Update-AzConnectedMachineExtension
Update-AzConnectedMachineRunCommand
Update-AzConnectedPrivateLinkScopeTag
				
			

How to install Az.ConnectedMachine PowerShell module

You can install the Az.ConnectedMachine PowerShell module directly from the PowerShell console. For the module installation, use the following command:

				
					Install-Module -Name Az.ConnectedMachine -Verbose -Force

				
			

Please remember that you need to set up the Azure Arc on your Azure environment before you can onboard any machine.

How to onboard local machine

  1. Open PowerShell as an administrator
  2. Execute the Connect-AzAccount command to connect to Azure
  3. Change the Subscription if needed using the Set-AzContext command
  4. Run the following command to onboard the local machine to Azure Arc:
				
					$OnboardingDetails = @{
    ResourceGroupName = "RG-PROD-IT-ARC"
    Name = $env:COMPUTERNAME.ToUpper()
    Location = "West Europe"
}
Connect-AzConnectedMachine @OnboardingDetail
				
			

If you have a lot of subscriptions, then you can also use the -SubscriptionId parameter in Connect-AzConnectedMachine, which doesn’t require a context change before onboarding.

How to onboard a remote machine

  1. Open PowerShell as an administrator
  2. Execute the Connect-AzAccount command to connect to Azure
  3. Change the Subscription if needed using the Set-AzContext command
  4. Create a new PowerShell Remoting session against the remote machine using the New-PSSession command
  5. Run the following command to onboard the remote machine to Azure Arc
				
					$ServerName = "SERVER02"
$PSRemoteSession = New-PSSession -ComputerName $ServerName

$OnboardingDetails = @{
    ResourceGroupName = "RG-PROD-IT-ARC"
    Location = "West Europe"
    PSSession = $PSRemoteSession
}

Connect-AzConnectedMachine @OnboardingDetails
				
			

You can also create multiple remote sessions against many machines, and you can onboard many machines at the same time.

Conclusion

Connecting machines to Azure Arc doesn’t have to be a complex process. With the Az.ConnectedMachine PowerShell module, you can easily onboard machines to Azure Arc, regardless of whether they’re local or remote. So why wait? Start leveraging the power of Azure Arc today!

Leave a Reply

Contact me

If you’re interested in learning about Maximize Your Cloud Reach: Connect On-Premises Machines to Azure Arc with PowerShell. I can help you understand how this solution can benefit your organization and provide a customized solution tailored to your specific needs.

Table of Contents