Azure Arc VM Onboarding Pt.3 – Post-Deployment Task Automation

Azure Arc VM Onboarding Pt.3 – Post-Deployment Task Automation

In this final blogpost on onboarding, I want to cover a way to automate some common post-deployment configuration tasks. When a machine is Arc onboarded, by default, it won’t really have much installed and it’s not particularly useful until you start deploying extensions.

Common post-deployment tasks

The goal for this automation was to provide a flexible system that will trigger whenever a new Arc onboarded VM is detected and perform a set number of tasks:

  • Tag the machine as ‘onboarding’
  • Install the OpenSSH extension
  • Deploy a public SSH key (using a Run command)
  • Configure SSH Arc Proxy endpoints
  • Enable Azure Benefits
  • Tag the machine as ‘onboarded’ with completion date/time

However, this is by no means an exhaustive list. For example, some organizations may choose to add tasks such as:

  • Automatic tagging based on hostname or other criteria
  • Moving VM resource to another Resource Group based on hostname or other criteria
  • Onboarding to Azure Update Manager (including Hotpatching for Server 2025)
  • Onboarding to Defender for Cloud and tag them
  • Deploy other extensions (such as Windows Admin Center or the Hybrid Worker Extension)
  • Onboarding to Extended Security Updates (ESU)
  • Adding the Managed Identity to a group (to assign permissions)
  • Onboarding to Log Analytics

The list can be as long as required and customized to suit any requirement.

Architecture Diagram

The core of the solution is an Azure Function App that is triggered by an Event Hub Subscription which monitors for successful creation events in a specified onboarding resource group. Once a new Arc machine is onboarded, the Azure Function App is triggered and completes the required tasks.

Showcase

Below is a screenshot of a machine I’ve just freshly Arc-onboarded using the classic script method (since this is just a lab environment:

Within seconds of the machine being created within Azure, Event Grid has sent a notification to the Function App which parses the result, identifies the new machine, tags it, and begins installing the SSH extension:

Within Azure, this can be seen with the temporary onboarding tag (also note that Azure benefits have not yet been activated):

Under extensions, the WindowsOpenSSH status shows it is being installed (this can take a few minutes; hence a durable function is best to use here):

After the completion of the Azure Function run, the machine now shows the completed tags and Azure benefits have been activated:

On the machine itself we can verify that a public SSH key has been installed:

To test we can now manage this machine through Ansible using the SSH key (off course, I get prompted to verify the key fingerprint for the first time connecting:

Security Considerations

As outlined in the previous blogposts regarding the Arc Onboarding service principal, if that is compromised, a threat actor could onboard their own machine and triggering the automation. This means care should be taken in both protecting and rotating the secret of the Service Principal but also ensuring that the automation doesn’t deploy additional secret information. For example, the public SSH key does not ever contain the private key.

Conclusion

Automating post-deployment tasks for Arc using other Azure services showcases the power and flexibility the cloud can provide even for systems not natively in Azure. I hope this inspires more automations related to hybrid infrastructure and utilizing Azure’s control plane.

If you’re interested in deploying this solution, please reach out!

Author

Table of Contents

Share this post
Search blog posts
Search
Authors
Modern Workplace consultant and a Microsoft MVP in Enterprise Mobility.

Modern Workplace consultant and a Microsoft MVP in Windows and Devices.

Infrastructure architect with focus on Modern Workplace and Microsoft 365 security.

Cloud & security specialist with focus on Microsoft backend products and cloud technologies.

Cloud & security specialist with focus on Microsoft 365.

Cloud & Security Specialist, with a passion for all things Cybersecurity

Cloud and infrastructure security specialist with background in networking.

Infrastructure architect with focus on design, implementation, migration and consolidation.

Infrastructure consultant with focus on cloud solutions in Office365 and Azure.

Modern workplace and infrastructure architect with a focus on Microsoft 365 and security.

follow us in feedly
Categories
  • Follow on SoMe