Skip to content

Latest commit

 

History

History
122 lines (74 loc) · 5.88 KB

local_vagrant_windows.md

File metadata and controls

122 lines (74 loc) · 5.88 KB

Onboard a local Windows server hosted with Vagrant into Azure Arc

The following README will guide you on how to deploy a local "Ready to Go" Windows 10 virtual machine using Vagrant and connect it as an Azure Arc enabled server resource.

Prerequisites

  • Clone this repo

    git clone https://github.com/microsoft/azure_arc.git
    
  • Install or update Azure CLI. Azure CLI should be running version 2.7 or later. Use az --version to check your current installed version.

  • Vagrant relies on an underlying hypervisor. For the purpose of this guide, we will be using "Oracle VM VirtualBox".

    • Install VirtualBox.

      • If you are an OSX user, simply run brew cask install virtualbox
      • If you are a Windows user, you can use the Chocolatey package
      • If you are a Linux user, all package installation methods can be found here
    • Install Vagrant

      • If you are an OSX user, simply run brew cask install vagrant
      • If you are a Windows user, you can use the Chocolatey package
      • If you are a Linux user, look here
  • Create Azure Service Principal (SP)

    To connect the Vagrant virtual machine to Azure Arc, an Azure Service Principal assigned with the "Contributor" role is required. To create it, login to your Azure account run the below command (this can also be done in Azure Cloud Shell).

    az login
    az ad sp create-for-rbac -n "<Unique SP Name>" --role contributor

    For example:

    az ad sp create-for-rbac -n "http://AzureArcServers" --role contributor

    Output should look like this:

    {
    "appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "displayName": "AzureArcServers",
    "name": "http://AzureArcServers",
    "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "tenant": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
    

    Note: It is optional but highly recommended to scope the SP to a specific Azure subscription and Resource Group

  • Azure Arc enabled servers is leveraging the Microsoft.HybridCompute resource provider (RP). Using the bellow command, register the RP.

    az provider register --namespace 'Microsoft.HybridCompute'
  • The Vagrantfile executes a script on the VM OS to install all the needed artifacts as well to inject environment variables. Edit the scripts/vars.ps1 Powershell script to match the Azure Service Principal you've just created.

    • subscriptionId=Your Azure Subscription ID
    • appId=Your Azure Service Principal name
    • password=Your Azure Service Principal password
    • tenantId=Your Azure tenant ID
    • resourceGroup=Azure Resource Group Name
    • location=Azure Region

Deployment

Like any Vagrant deployment, a Vagrantfile and a Vagrant Box is needed. At a high-level, the deployment will:

  1. Download the Windows 10 image file Vagrant Box
  2. Execute the Arc installation script

After editing the scripts/vars.ps1 script to match your environment, from the Vagrantfile folder, run vagrant up. As this is the first time you are creating the VM, the first run will be much slower than the ones to follow. This is because the deployment is downloading the Windows 10 box for the first time.

Once the download is complete, the actual provisioning will start. As you can see in the screenshot below, the process takes can take somewhere between 7 to 10 minutes.

Upon completion, you will have a local Windows 10 VM deployed, connected as a new Azure Arc enabled server inside a new Resource Group.

Semi-Automated Deployment (Optional)

As you may noticed, the last step of the run is to register the VM as a new Azure Arc enabled server resource.

In a case you want to demo/control the actual registration process, to the following:

  1. In the install_arc_agent Powershell script, comment out the "Run connect command" section and save the file. You can also comment out or change the creation of the Resource Group.

  1. RDP the VM using the vagrant rdp command. Use vagrant/vagrant as the username/password.

  1. Open Powershell ISE as Administrator and edit the C:\runtime\vars.ps1 with your environment variables.

  1. Paste the Invoke-Expression "C:\runtime\vars.ps1" commmand, the az group create --location $env:location --name $env:resourceGroup --subscription $env:subscriptionId command and the same azcmagent connect command you've just commented and execute the script.

Delete the deployment

To delete the entire deployment, run the vagrant destroy -f command. The Vagrantfile includes a before: destroy Vagrant trigger which will run the command to delete the Azure Resource Group before destroying the actual VM. That way, you will be starting fresh next time.