Deploy a local Ubuntu server hosted with Vagrant and connect it to Azure Arc
This article provides guidance for deploying a local Ubuntu virtual machine using Vagrant and connects it as an Azure Arc-enabled server resource.
Prerequisites
Clone the Azure Arc Jumpstart repository.
git clone https://github.com/microsoft/azure_arc.git
Install or update Azure CLI to version 2.7 and above. Use the following command to check your current installed version.
az --version
Vagrant relies on an underlying hypervisor. For this guide, we are using Oracle VM VirtualBox.
Install VirtualBox.
- If you're a macOS user, run
brew cask install virtualbox
- If you're a Windows user, you can use the Chocolatey package
- If you're a Linux user, all package installation methods can be found in Download VirtualBox for Linux hosts.
- If you're a macOS user, run
Install Vagrant
- If you're a macOS user, run
brew cask install vagrant
- If you're a Windows user, you can use the Chocolatey package
- If you're a Linux user, visit the Vagrant download page.
- If you're a macOS user, run
Create an Azure service principal.
To connect the Vagrant virtual machine to Azure Arc, an Azure service principal assigned with the Contributor role is required. To create it, sign in to your Azure account and run the following command. You can also run this command in Azure Cloud Shell.
az login az account set -s <Your Subscription ID> az ad sp create-for-rbac -n "<Unique SP Name>" --role contributor --scopes "/subscriptions/<Your Subscription ID>"
For example:
az ad sp create-for-rbac -n "http://AzureArcServers" --role contributor --scopes "/subscriptions/00000000-0000-0000-0000-000000000000"
The output should look like this:
{ "appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "displayName": "http://AzureArcServers", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "tenant": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
Note
We highly recommend that you scope the service principal to a specific Azure subscription and resource group.
The Vagrant file executes a script on the VM OS to install all the needed artifacts and to inject environment variables. Edit the
scripts/vars.sh
shell script to match the Azure service principal you created.subscriptionId
= your Azure subscription IDappId
= your Azure service principal namepassword
= your Azure service principal passwordtenantId
= your Azure tenant IDresourceGroup
= Azure resource group namelocation
= Azure region
Deployment
Like any Vagrant deployment, a vagrantfile and a Vagrant box is needed. At a high-level, the deployment will:
- Download the Ubuntu 16.04 image file Vagrant box
- Execute the installation script
After editing the scripts/vars.sh
script to match your environment, from the Vagrantfile
folder, run vagrant up
. Since this is the first time creating the VM, the first run will be much slower than the ones to follow, because the deployment is downloading the Ubuntu box for the first time.
Once the download is complete, the provisioning begins. As shown in the following screenshot, the process takes no longer than three minutes.
Upon completion, you'll have a local Ubuntu VM deployed, connected as a new Azure Arc-enabled server, inside a new resource group.
Semi-automated deployment (optional)
The last step is to register the VM as a new Azure Arc-enabled server resource.
If you want to demo/control the actual registration process, complete the following steps:
In the
install_arc_agent
shell script, comment out therun connect command
section and save the file. You can also comment out or change the creation of the resource group.SSH to the VM using the
vagrant ssh
command.Run the same
azcmagent connect
command you commented out using your environment variables.
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 a script to delete the Azure resource group before destroying the actual VM.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for