The Microsoft Connected Machine agent, often referred to as the Arc agent, is a critical component for managing and governing your on-premises and multi-cloud servers within the Azure environment. It allows you to extend Azure management services to your machines regardless of where they reside, bringing them under the umbrella of Azure Resource Manager. This includes capabilities like Azure Policy, Azure Security Center, Update Management, and more. This article provides a comprehensive guide on how to install the Arc agent, covering various deployment scenarios and troubleshooting tips.
Understanding The Arc Agent And Its Benefits
Before diving into the installation process, it’s crucial to understand what the Arc agent is and why it’s beneficial. The Arc agent isn’t a traditional agent that constantly pushes data to Azure. Instead, it acts as a bridge, enabling Azure to communicate with your servers using standard protocols. This means you don’t need to migrate your existing infrastructure to Azure to benefit from its management features.
The primary benefits of using the Arc agent include:
- Centralized Management: Manage all your servers, whether on-premises, in other clouds (AWS, GCP), or at the edge, from a single pane of glass within the Azure portal.
- Azure Policy Enforcement: Apply Azure policies to your non-Azure servers, ensuring compliance and security standards are met across your entire infrastructure.
- Azure Security Center Integration: Extend Azure Security Center’s threat detection and vulnerability assessment capabilities to your hybrid environment.
- Update Management: Automate patching and updates for your servers, reducing the risk of security vulnerabilities.
- Simplified Governance: Improve governance and compliance by managing your entire IT estate using Azure’s robust management tools.
- Automation and Scripting: Utilize Azure Automation to automate tasks on your connected machines, streamlining operations.
Prerequisites For Installing The Arc Agent
Before you begin the installation, ensure you have the necessary prerequisites in place. Failing to meet these requirements can lead to installation errors or unexpected behavior.
Here’s a checklist of prerequisites:
- Azure Subscription: You need an active Azure subscription. If you don’t have one, you can create a free account.
- Azure Permissions: You need appropriate permissions to register machines with Azure Arc. The “Azure Connected Machine Onboarding” role is generally sufficient, along with permissions to create resource groups if necessary.
- Supported Operating System: The Arc agent supports a wide range of operating systems, including Windows Server and various Linux distributions (Ubuntu, Red Hat, CentOS, SUSE, etc.). Check the official Microsoft documentation for the most up-to-date list of supported operating systems and their versions.
- Connectivity: The machine you’re connecting needs outbound connectivity to Azure services over HTTPS (port 443). Specific URLs are required, which are detailed in the Microsoft documentation.
- Service Principal (Optional): For automated deployments or deployments at scale, using a service principal is recommended. You’ll need to create a service principal with the “Contributor” role at the scope where you want to register the machines.
- PowerShell or Bash: Depending on your operating system and deployment method, you’ll need PowerShell (for Windows) or Bash (for Linux) installed.
- Azure CLI (Recommended): While not strictly required, the Azure CLI is highly recommended for managing Azure resources and generating the installation script.
- Hybrid Connectivity (Proxy Server): If your server requires to go through a proxy server, make sure that the Arc Agent is configured to connect via the proxy server.
Step-by-Step Installation Guide
The installation process involves downloading the agent package, configuring it with your Azure details, and running the installation script. The following sections outline the steps for both Windows and Linux environments.
Installing The Arc Agent On Windows Server
-
Login to the Azure Portal: Open your web browser and navigate to the Azure portal (portal.azure.com).
-
Search for Azure Arc: In the search bar at the top of the portal, type “Azure Arc” and select “Azure Arc” from the results.
-
Add a Machine: On the Azure Arc overview page, click on “Add” under “Servers.”
-
Generate the Installation Script:
- Select “Add servers using interactive script.”
- Specify the resource group where you want to register the machine. If the resource group doesn’t exist, create a new one.
- Choose the region for the metadata of the connected machine. Select a region geographically closest to your machine.
- Select the operating system (Windows).
- Choose the connectivity method (public endpoint or private endpoint).
- If you’re using a proxy server, configure the proxy settings.
- Review the script and click “Download.” This will download a PowerShell script.
-
Run the PowerShell Script:
- Copy the downloaded PowerShell script to the Windows Server you want to connect.
- Open PowerShell as an administrator.
- Navigate to the directory where you saved the script.
- Execute the script using the command:
.\OnboardingScript.ps1
(replace “OnboardingScript.ps1” with the actual name of your script). - The script will download the Arc agent, configure it with your Azure details, and register the machine with Azure Arc.
-
Verify the Installation:
- After the script completes successfully, go back to the Azure portal and navigate to the resource group you specified earlier.
- You should see a new resource representing your connected Windows Server.
- The status of the machine should be “Connected.”
Installing The Arc Agent On Linux
-
Login to the Azure Portal: Open your web browser and navigate to the Azure portal (portal.azure.com).
-
Search for Azure Arc: In the search bar at the top of the portal, type “Azure Arc” and select “Azure Arc” from the results.
-
Add a Machine: On the Azure Arc overview page, click on “Add” under “Servers.”
-
Generate the Installation Script:
- Select “Add servers using interactive script.”
- Specify the resource group where you want to register the machine. If the resource group doesn’t exist, create a new one.
- Choose the region for the metadata of the connected machine. Select a region geographically closest to your machine.
- Select the operating system (Linux).
- Choose the connectivity method (public endpoint or private endpoint).
- If you’re using a proxy server, configure the proxy settings.
- Review the script and click “Download.” This will download a Bash script.
-
Run the Bash Script:
- Copy the downloaded Bash script to the Linux server you want to connect.
- Open a terminal.
- Navigate to the directory where you saved the script.
- Make the script executable using the command:
chmod +x ./OnboardingScript.sh
(replace “OnboardingScript.sh” with the actual name of your script). - Execute the script using the command:
sudo ./OnboardingScript.sh
(you’ll likely need sudo privileges). - The script will download the Arc agent, configure it with your Azure details, and register the machine with Azure Arc.
-
Verify the Installation:
- After the script completes successfully, go back to the Azure portal and navigate to the resource group you specified earlier.
- You should see a new resource representing your connected Linux server.
- The status of the machine should be “Connected.”
Automated Deployment Using A Service Principal
For large-scale deployments, using a service principal is highly recommended to automate the installation process. A service principal is a security identity within Azure Active Directory that applications, services, and automation tools can use to access specific Azure resources.
Here’s how to use a service principal for Arc agent installation:
-
Create a Service Principal: You can create a service principal using the Azure CLI.
bash
az ad sp create-for-rbac --name "ArcAgentSP" --role "Contributor" --scopes "/subscriptions/<your_subscription_id>"Replace
<your_subscription_id>
with your Azure subscription ID.
Important: Securely store theappId
andpassword
(orclientSecret
) that are outputted after running the command. These are the credentials for your service principal. -
Modify the Installation Script:
- When generating the installation script in the Azure portal, select the option to use a service principal.
- Provide the
appId
(client ID),password
(client secret), and tenant ID of your service principal.
-
Run the Script: Execute the generated script as described in the previous sections for Windows or Linux. The script will use the service principal credentials to authenticate with Azure, automating the registration process.
Troubleshooting Common Issues
While the installation process is generally straightforward, you might encounter some common issues. Here are some troubleshooting tips:
- Connectivity Problems: If the script fails to download the agent package or connect to Azure services, check your network connectivity. Ensure that the server has outbound access to the required Azure endpoints over HTTPS (port 443). If you’re using a proxy server, verify that the proxy settings are correctly configured in the script.
- Permission Errors: If you encounter permission errors, make sure you’re running the script with administrator privileges (on Windows) or using
sudo
(on Linux). Also, verify that the Azure account you’re using has the necessary permissions to register machines with Azure Arc. - Agent Not Connecting: After the installation completes, it might take a few minutes for the agent to connect to Azure. If the machine’s status in the Azure portal remains “Disconnected” for an extended period, check the agent logs on the server for any errors.
- Windows: The agent logs are typically located in
C:\ProgramData\AzureConnectedMachineAgent\Log
. - Linux: The agent logs are typically located in
/var/opt/azcmagent/log
.
- Windows: The agent logs are typically located in
- Script Errors: Carefully review the error messages displayed in the terminal or PowerShell window when running the script. These messages often provide clues about the cause of the problem. Double-check that you’ve provided the correct Azure subscription ID, resource group name, and other configuration parameters.
- Proxy Configuration Issues: Incorrect proxy server settings are a common cause of installation failures. Ensure that the proxy server is reachable from the server you’re trying to connect and that the proxy settings are correctly configured in the installation script. Check to make sure that the proxy address is in the format of
http://<proxy_address>:<proxy_port>
orhttps://<proxy_address>:<proxy_port>
. - DNS Resolution: Ensure that the server can resolve the necessary Azure service endpoints through DNS. If you’re using a custom DNS server, verify that it’s correctly configured to resolve Azure’s DNS names.
- Time Synchronization: Ensure that the server’s time is synchronized with a reliable time source. Time synchronization issues can sometimes cause authentication problems.
Verifying The Agent Installation
After installing the Arc agent, it’s crucial to verify that it’s functioning correctly. Here are several ways to verify the installation:
-
Azure Portal: As mentioned earlier, the primary way to verify the installation is by checking the status of the connected machine in the Azure portal. Navigate to the resource group where you registered the machine and look for the resource representing your server. The status should be “Connected.”
-
Agent Status Command: The Arc agent provides a command-line tool that you can use to check its status.
- Windows: Open PowerShell as an administrator and run the command:
azcmagent show
- Linux: Open a terminal and run the command:
azcmagent show
This command will display information about the agent, including its status, version, and configuration settings.
- Windows: Open PowerShell as an administrator and run the command:
-
Agent Logs: As mentioned in the troubleshooting section, the agent logs contain valuable information about its operation. Check the logs for any errors or warnings that might indicate a problem.
-
Azure Activity Log: You can also check the Azure Activity Log for events related to the connected machine. This can help you track when the machine was registered, when policies were applied, and other relevant events.
-
Azure Resource Graph Explorer: Use Azure Resource Graph Explorer to query all connected machines and their properties. This is helpful for verifying the installation across a large number of servers.
Uninstalling The Arc Agent
If you need to uninstall the Arc agent, follow these steps:
-
Windows:
- Open the Control Panel and go to “Programs and Features.”
- Find the “Azure Connected Machine Agent” in the list of installed programs.
- Select the agent and click “Uninstall.”
- Follow the on-screen prompts to complete the uninstallation.
- Delete the connected machine resource in the Azure Portal.
-
Linux:
- Open a terminal.
- Run the following command:
sudo /opt/azcmagent/uninstall.sh
- Follow the on-screen prompts to complete the uninstallation.
- Delete the connected machine resource in the Azure Portal.
Important: After uninstalling the agent, it’s essential to delete the corresponding resource in the Azure portal to remove the machine from your Azure inventory.
Conclusion
Installing the Microsoft Connected Machine agent (Arc agent) is a crucial step in extending Azure management and governance capabilities to your hybrid and multi-cloud environments. By following the steps outlined in this article, you can successfully install the agent on your Windows and Linux servers, automate the deployment process using a service principal, and troubleshoot common issues. Remember to regularly monitor the agent’s status and logs to ensure it’s functioning correctly and providing the desired level of management and security for your connected machines. The centralization of server management is a huge advantage in modern infrastructure.