Connect an existing Windows Server instance to Azure Arc
This article provides guidance for connecting a Windows machine to Azure Arc using a simple PowerShell script.
Prerequisites
Install or update Azure CLI to version 2.7 and above. Use the following command to check your current installed version.
az --versionCreate an Azure service principal.
To connect a server to Azure Arc, an Azure service principal assigned with the Contributor role is required. To create it, sign in to your Azure account and run the following command. You can also run this command in Azure Cloud Shell.
az login az ad sp create-for-rbac -n "<Unique SP Name>" --role contributorFor example:
az ad sp create-for-rbac -n "http://AzureArcServers" --role contributorOutput should look like this:
{ "appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "displayName": "AzureArcServers", "name": "http://AzureArcServers", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "tenant": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }Note
We highly recommend that you scope the service principal to a specific Azure subscription and resource group.
Create a new Azure resource group for your machines.

Download the
az_connect_win.ps1PowerShell script.Change the environment variables according to your environment and copy the script to the designated machine.

Deployment
On the designated machine, open PowerShell ISE as Administrator and run the script. Note the script is using $env:ProgramFiles as the agent installation path, so ensure you are not using PowerShell ISE (x86).


Upon completion, you will have your Windows Server instance, connected as a new Azure Arc resource inside your resource group.



Delete the deployment
To delete the server, select the server and delete it from the Azure portal.

To delete the entire deployment, delete the Azure resource group from the Azure portal.
