How to Set Up Azure Automation for Agent Installation

Overview

This document outlines the steps to set up Azure Automation for agent installation. 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.

Table of Contents

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.

      dwg trueviewer

      dwg trueviewer

        • Click on the Create Storage Account

      dwg trueviewer

        • Enter the storage account name: ecagentbinary.

          dwg trueviewer

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

      dwg trueviewer

      • Wait for the deployment to finish, then click Go to resource.

dwg trueviewer

    1. Upload the Agent File:
        • In the storage account, navigate to Overview and click Upload.

      dwg trueviewer

        • Upload the file: Downloaded Agent File.

      dwg trueviewer

      • Set the container name as scriptcontainer.

        dwg trueviewer

        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.

dwg trueviewer

dwg trueviewer

    1. Generate a SAS Token:
        • Right-click on LocalOffice_Agent.exe and select Generate SAS.

      dwg trueviewer

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

      dwg trueviewer

      • Copy the Blob SAS URL.

dwg trueviewer

  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.

    dwg trueviewer

    • Save the file as InstallAgentAzure.ps1.
    • Upload InstallAgentAzure.ps1 to the same scriptcontainer.

dwg trueviewer

Finalize Storage Container Contents

Your scriptcontainer should now contain:

  • LocalOffice_Agent.exe
  • InstallAgentAzure.ps1

dwg trueviewer

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.

      dwg trueviewer

        • Choose your resource group.

      dwg trueviewer

        • Name the Automation account: agentinstallation.

      dwg trueviewer

        • In the Advanced tab Select System Managed Identity.

      dwg trueviewer

      • Review your settings and click Create.

dwg trueviewer

    1. Enable System Managed Identity:
        • Once the deployment completes, click Go to resource.

      dwg trueviewer

      • Search for Identity and toggle System Managed Identity to On.

dwg trueviewer

  1. Assign Roles:
      • Click Azure role assignments and use Add role assignmentto assign the following roles:

        dwg trueviewer

          • Role 1:
            • Scope: Resource group
            • Subscription: Your target subscription
            • Role: Virtual Machine Contributor

        dwg trueviewer

        • Role 2:
          • Scope: Storage
          • Subscription: Your target subscription
          • Resource: ecagentbinary
          • Role: Storage Blob Data Contributor

    dwg trueviewer

    • Wait a few minutes to verify that the roles are assigned.

dwg trueviewer

Step 4: Create a New Runbook

    1. Go to the Automation Account and select Runbooks.

dwg trueviewer

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

dwg trueviewer

dwg trueviewer

    1. Edit the Runbook:
        • Download the scriptbelow and copy the link and paste it into the editor

      dwg trueviewer

      dwg trueviewer

      • Save and publish the runbook.

dwg trueviewer

dwg trueviewer

  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.

dwg trueviewer

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

dwg trueviewer

    • az.compute

dwg trueviewer

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.