Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Task 02 - Run script to add server to Azure Arc

Introduction

Tailspin Toys needs to add the simulated on-premises Windows Server 2012 VM to Azure Arc by running the generated onboarding script.

Description

In this task, you will run the onboarding script to install the Azure Arc agent.

Success Criteria

  • Script executed successfully.
  • Confirmation message: “Connected machine to Azure.””
  • Azure Arc resource URL displayed.

Solution

Expand this section to view the solution
  1. In the Azure Portal, navigate to the Resource Group for the lab, then select the tailspin-onprem-hyperv-vm virtual machine resource. This is the simulated on-premises Hyper-V host VM.

    The resource group for the lab is shown with the simulated on-premises Windows Server 2012 VM highlighted in the resource list.

  2. On the left, select Bastion under Connect.

    The virtual machine pane for the simulated on-premises hyper-v host VM is shown with the Bastion link under Operations highlighted.

  3. Enter the Username and Password, then select Connect.

    IMPORTANT: When the VM was created the credentials were set up as:

    • Username: demouser
    • Password: demo!pass123

    The Bastion pane is shown for the VM with the Username and Password values entered and fields highlighted.

    NOTE: When running the PowerShell script later in this task, the script will open a browser window to authenticate your Azure account. Because of this, we need to set Microsoft Edge as the default browser in the VM before proceeding to the next steps.

  4. Once connected to the VM, type default at the Start menu. Select Default Programs to open it.

    The Start menu is shown with Default Programs highlighted.

  5. In the Default Programs window, select Set your default programs.

    The Default Programs window is shown with the Set your default programs option highlighted.

  6. In the Set Default Programs window, select Microsoft Edge from the list on the left, then select Set this program as default. Select OK to close the window.

    The Set Default Programs window is shown with Microsoft Edge selected and the Set this program as default option highlighted.

  7. Open the Start menu, then type powershell at the Start menu. Right-click Windows PowerShell ISE, then select Run as administrator.

    The Start menu is shown with Windows PowerShell ISE highlighted and the Run as administrator option selected.

  8. Within Windows PowerShell ISE, create a New script file and paste in the contents of the previously downloaded Azure Arc OnboardingScript.ps1 script.

    The Windows PowerShell ISE window is shown with a new script file open.

  9. Important! New versions of the Azure Arc Connected Machine agent will not work on Windows Server 2012 R2. Because of this, we need to modify the PowerShell script to include the -AltDownload parameter to the agent install script. This sets the Connected Machine agent download path to an older version (1.50), which is compatible with Windows Server 2012 R2.

    Locate the following line in the script:

     # Install the hybrid agent
     & "$installScriptPath"
    

    And modify it to include the -AltDownload parameter:

     # Install the hybrid agent
     & "$installScriptPath" -AltDownload "https://gbl.his.arc.azure.com/azcmagent/1.50/AzureConnectedMachineAgent.msi";
    

    The updated code should look like the following:

    The updated onboarding script.

  10. Run the script by selecting the Run Script (green play) button or pressing F5. This will install the Azure Arc agent and Arc-enable the VM. When the script opens a browser window, enter your credentials to authenticate with Azure.

    NOTE: When the Azure Arc script opens a new browser window to authenticate you with Azure, be sure to use an Organization Account with permissions to create Microsoft.HybridCompute/machines resources. Using a Personal Account is not supported and will result in a AZCM0042: Failed to Create Resource error message.

  11. When the script finishes executing successfully, a message stating “Connected machine to Azure” will be shown, along with the Azure Portal resource URL for the Azure Arc-enabled Server.

    The command line output of the Azure Arc script is shown that includes the Connected machine to Azure message showing the script executed successfully.