×
×
×
×

How to Set Up Azure Automation for Agent Installation

Overview

This document outlines the steps to set up Azure Automation for agent installation in virtual machine. It provides detailed instructions for downloading agent files, creating storage and automation accounts, and managing roles and runbooks in Azure. By following these steps, you will be able to automate the installation of agents in your Azure environment efficiently.

Prerequisites

  • Azure Subscription: Ensure you have an active Azure subscription.
  • Automation Account: Create an Automation account to manage runbooks and authenticate to Azure resources.
  • Storage Account: Create a storage account to store agent binaries and scripts.

Step 1: Download the Agent Installation Files

    1. Access Endpoint Central
      • Log in to the Endpoint Central web console.
      • Navigate to Agent > Computers.
      • Select the remote office and click on Download Agent.

Step 2: Create a Storage Account

    1. Login to the Azure Portal
    2. Create a Storage Account
      • Go to All services and select Storage Accounts.

      Selecting Storage Accounts from All services in the Azure portal

      The Azure Storage Accounts page
      • Click on the Create Storage Account

      Clicking Create on the Storage Accounts page
        • Enter the storage account name: ecagentbinary.

          Entering the storage account name ecagentbinary
          Note
          If you use a different name, update the Automation runbook script accordingly.
        • Modify default settings as needed and click Create.

      Reviewing storage account settings before clicking Create
      • Wait for the deployment to finish, then click Go to resource.

Storage account deployment complete, with the Go to resource option
  1. Upload the Agent File:
    • In the storage account, navigate to Overview and click Upload.

    Clicking Upload from the storage account Overview page
    • Upload the file: Downloaded Agent File.

    Selecting the downloaded agent installer file to upload
    • Set the container name as scriptcontainer.

      Setting the container name to scriptcontainer during upload
      Note
      If you use a different name, update the Automation runbook script accordingly.
    • After the upload completes, go to the Containers tab and open scriptcontainer.

Opening scriptcontainer from the Containers tab

scriptcontainer showing the uploaded agent file
    1. Generate a SAS Token:
        • Right-click on LocalOffice_Agent.exe and select Generate SAS.

      Selecting Generate SAS on LocalOffice_Agent.exe
        • Set the expiration date and allowed protocol, then click Generate SAS token and URL.

      Setting the expiration date and allowed protocol for the SAS token
      • Copy the Blob SAS URL.

Copying the generated Blob SAS URL
  1. Prepare the Installation Script:
      • Download the attached script and open it in a text editor.
      • Replace the placeholder LocalOffice_Agent.exe Agent_MSI_URL with the Blob SAS URL.

    Replacing the placeholder in the script with the Blob SAS URL
    • Save the file as InstallAgentAzure.ps1.
    • Upload InstallAgentAzure.ps1 to the same scriptcontainer.

Uploading InstallAgentAzure.ps1 to the scriptcontainer

Finalize Storage Container Contents

Your scriptcontainer should now contain:

  • LocalOffice_Agent.exe
  • InstallAgentAzure.ps1

scriptcontainer showing LocalOffice_Agent.exe and InstallAgentAzure.ps1

Step 3: Create an Azure Automation Account

    1. Login to the Azure Portal.
    2. Create an Automation Account:
        • Navigate to Automation Accounts and click Add.

      Clicking Add on the Automation Accounts page
        • Choose your resource group.

      Choosing the resource group for the automation account
        • Name the Automation account: agentinstallation.

      Naming the automation account agentinstallation
        • In the Advanced tab Select System Managed Identity.

      Selecting System Managed Identity in the Advanced tab
      • Review your settings and click Create.

Reviewing automation account settings before clicking Create
    1. Enable System Managed Identity:
        • Once the deployment completes, click Go to resource.

      Automation account deployment complete, with the Go to resource option
      • Search for Identity and toggle System Managed Identity to On.

Toggling System Managed Identity to On under Identity
  1. Assign Roles:
      • Click Azure role assignments and use Add role assignmentto assign the following roles:

        Opening Azure role assignments to add role assignments
          • Role 1:
            • Scope: Resource group
            • Subscription: Your target subscription
            • Role: Virtual Machine Contributor

        Assigning the Virtual Machine Contributor role scoped to the resource group
        • Role 2:
          • Scope: Storage
          • Subscription: Your target subscription
          • Resource: ecagentbinary
          • Role: Storage Blob Data Contributor

    Assigning the Storage Blob Data Contributor role on the ecagentbinary storage account
    • Wait a few minutes to verify that the roles are assigned.

Verifying that the roles have been assigned

Step 4: Create a New Runbook

    1. Go to the Automation Account and select Runbooks.

Selecting Runbooks in the automation account
    1. Click Create a runbookand fill in the details:
      • Name: agentinstallation
      • Runbook type: PowerShell
      • Runtime version: 5.1
      • Click Review + Create.

Entering runbook details — name, PowerShell type, and runtime version 5.1

Reviewing the runbook details before creating
    1. Edit the Runbook:
        • Download the scriptbelow and copy the link and paste it into the editor

      Pasting the downloaded script into the runbook editor

      The runbook script in the editor
      • Save and publish the runbook.

Saving and publishing the runbook

Confirmation that the runbook has been published
  1. Start the Runbook:
    • Wait for the deployment to finish, then click Start once available.
    • Open the Jobs tab to monitor the status and check the output tab for execution results.

Starting the runbook and monitoring job status in the Jobs tab

Troubleshooting

In case of errors during script execution, ensure that the following two modules are imported in the Modules tab of the Automation account:

Run time 5.1

    • az.accounts

Importing the az.accounts module in the Modules tab
    • az.compute

Importing the az.compute module in the Modules tab

Conclusion

By following this guide, you have successfully set up Azure Automation for agent installation. This setup streamlines the process of deploying agents across your Azure environment, allowing for greater efficiency and easier management. If you encounter any issues or have questions, don't hesitate to seek further assistance.