Building VM Template or Golden Image with Azure ARC agent preinstalled?

Jeff Tapp 31 Reputation points
2022-05-26T20:11:57.927+00:00

Hello,

I've been working recently on adding our on-prem VMs to Azure via Azure ARC to utilize update management automation. So far everything has worked splendidly (aside from not being able to use VM tags for targeting groups of VMs but we were able to work around that). Now, since we are going to continue using on-prem VMs for the foreseeable future, I'd like to create a VM template that already has the agent installed. Is this possible? If so, what would be the recommended processes? I've read through all the deployment guides and I can't find any specific references to what I'd like to accomplish. I understand the service principle may be a bit of a challenge, but I'm willing to explore some creative options. Thanks!

Jeff

Azure Arc
Azure Arc
A Microsoft cloud service that enables deployment of Azure services across hybrid and multicloud environments.
399 questions
{count} vote

Accepted answer
  1. Stanislav Zhelyazkov 23,421 Reputation points MVP
    2022-05-27T12:43:14.18+00:00

    Hi,
    I believe this is not possible or at least not fully. You could probably install the actual agent but installing the agent is only one part. After installation you need to register the machine to Azure by using service principal credentials. This second part will have to be ran every time you spin up a new server from that image. You will need to install the agent every time. When you try to add ARC server you can choose bulk mode. This will give you a script to do that. From that script this is the part where the agent (windows) is installed and you can put into your image

    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12  
      
    # Download the installation package  
    Invoke-WebRequest -Uri "https://aka.ms/azcmagent-windows" -TimeoutSec 30 -OutFile "$env:TEMP\install_windows_azcmagent.ps1"  
      
    # Install the hybrid agent  
    & "$env:TEMP\install_windows_azcmagent.ps1"  
    if($LASTEXITCODE -ne 0) {  
        throw "Failed to install the hybrid agent"  
    }  
      
    

    The part after:

    # Run connect command  
    

    you will need to run every time a new machine is created from the image. That part registers the machine to Azure ARC by using that agent.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.