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 wants to migrate their on-premises SQL Server database to Azure SQL Managed Instance. In this task, you will run the script in the on-prem VM.

Description

In this task, you will run the script in the on-prem VM.

The key tasks are as follows:

  1. Run the script in the on-prem VM.
  2. After the script, a message stating “Connected machine to Azure” will be shown.

Success Criteria

  • Successfully run the script.
  • A message stating “Connected machine to Azure” will be shown after running the script.

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 Hyper-V Host 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.

    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.

  4. Once connected to the Hyper-V Host VM, open the Start menu, then search for and run the Hyper-V Manager.

  5. Within the Hyper-V Manager, double-click the OnPremVM VM to connect to it.

    The Hyper-V Manager is shown with the list of virtual machines displayed with the OnPremVM highlighted.

  6. Once connected to the OnPremVM VM within Hyper-V, sign in using the Administrator account and the password of demo!pass123.

    If you need to send a Ctrl + Alt + Delete command to the VM, under Action, select Ctrl+Alt+Delete.

    The CtrlAltDel action on the HyperV Manager with the option highlighted.

    If you encounter that the OnPremVM has No Internet Connection, go back into the tailspin-onprem-hyperv-vm Hyper-V Host VM and perform the following steps:

    • Open the View network connections.
    • Locate the Ethernet connection and right-click it.
    • Select Properties.
    • Select the Sharing tab.
    • Disable and re-enable Internet Connection Sharing on this connection.
    • Select OK

    You may see a warning message when disabling it and re-enabling it, but it will still work to restore Internet Connection Sharing with the OnPremVM that is connected through the Host VM’s network connection.

    The Ethernet connection properties on the Hyper-V Host VM showing Internet Connection Sharing option highlighted.

    Go back into the OnPremVM and perform the following steps:

    • Open Windows PowerShell
    • Execute command: ipconfig /flushdns
  7. Within the OnPremVM, open the Windows PowerShell ISE, and create a new script file.

  8. Paste in the contents of the Azure Arc OnboardingScript.ps1 script previously downloaded.

    Within the Hyper-V Virtual Machine Connection window, you may need to use the Clipboard -> Type clipboard text menu option to paste into the OnPremVM.

    If you are not able to copy and paste the entire content of the script at once, try doing it in chunks of text.

  9. Run the full script. 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.

    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.

  10. 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.