In previous posts we build an Azure Developer Environment. In this post we will provide an update on how best to create a developer environment for managing your cloud environment. Along the way we will describe not just what and how, but also why.
In this artical we shall cover the following topics:
- Working in the cloud
- Build a Windows Machine
- Deploy Linux on Windows
- Install Tools
- Create Project Environments
Lets Get started…
Work in the Cloud
I am an advocate for “fit for purpose”. Because our target environment is the cloud does not mean our development environment should also be in the cloud ? Depends.
If you employer or client is paying for the cloud subscription, then yes provision your development environment in the cloud. If you are working on independent projects and a bill of $30-60 a month is steep for you as a struggling college student – then work local.
The advantage of a cloud based machine is that allows you to purchase a business class laptop and remote into a virtual development machine from it or even grandmas PC over a holiday weekend. You can also keep your development machine just as you last left it right down to the mouse position without having to pivot from business use to developer use (think productivity).
Creating a Windows Machine VM
The best operating system to use for administration and automation is Linux (sorry Microsoft). This is because of the power of the command line and essential Linux command line tools such as npm, pip, grep, curl, sed, awk. in addition to development principals such as agile, devops, and infrastructure as code (IaC). You will see this in action other articles I’ve created [list articles here].
What… what? The article section says to use Windows…
The Windows Subsystem for Linux (wsl.exe) lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a virtual machine.
If you need to make a Windows 10 VM on Azure.
Install Visual Studion Code
Install Ubuntu Subsystem on Windows
Before installing any Linux distros for WSL, you must ensure that the “Windows Subsystem for Linux” optional feature is enabled:
- Open PowerShell as Administrator and run:PowerShellCopy
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart your computer when prompted.
Now head over the the Microsoft Store on Windows 10 and install the latest version of Ubuntu. It is important that you install the 18.04 version as the v20 does not play nice.
Getting started with WSL
It will first ask you to create an account. I recommend your first or nickname. Also something simple for the password.
First thing to update the environment from the base build.
sudo apt update && apt upgrade -y
With Ubuntu 20 .04 we get Python3 not Python but we do not get it’s package manger (PIP3) that allows us to install packages. Will we need this do fetch the packages we need for development.
sudo apt install python3-pip -y
Accessing Windows from WSL
The place to put your project files is where both WSL and Windows can access them. From WSL you can access root c drive windows files at
/mnt/c . You could simply work from your Documents folder under your user at
/mnt/c/Users/<account>/Documents but a better solution is to cloud file storage tool like OneDrive, DropBox, etc.
You do not want to have to constantly have to cd to that entire path each time you access WSL. best to create an evnrionment variable similar to a path on windows.
export code=$/mnt/c/Users/<account>/OneDrive/code cd $code
Create Project Environments
Their is a basic problem to all development about dependencies and versions, and indirectly permissions of those packages we discuss previously. Imagine you have an application that needs version
LibFoo, but another application requires version
2. How can you use both these libraries? If you install everything into your host python (e.g.
python3.8) it’s easy to end up in a situation where two packages have conflicting requirements.
In order to address this issue there are tools that we can use to create virtual project scoped environments.
pip3 install virtualenv
you will notice that pip package installers are different than apt
. bin/activatelsthink about that for a second. We are in the cloud on a hardware virtual environment (Windows VM), in Linux virtual operating system environment (WSL), working in a project virtual environment. Cool Hu ?
Now we are ready to create our first project
Change directories to the project folder. You will see a /bin and /lib folder.
To activate the virtual environment simply type
To deactivate the virtual environment simply type
Install Azure CLI
Microsoft offers two ways to install the Azure CLI with distributions that support
apt: As an all-in-one script that runs the install commands for you, and instructions that you can run as a step-by-step process on your own.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
you can verify that the azure cli is installed by typing “az”
Not that we have the Azure CLI installed we have to log into our azure subscription in order to manage it.
First we need to like all the various client environments, this is imporant if you support commercial (Global Azure) and government (Azure Gov) customers.
az cloud list --output table
If needed you can set the cloud environment needed
az cloud set --name AzureUSGovernment
if that is not needed you can simply log into the cloud
az login -u <account> -p <password>
Once you have authenicated you can then list out the subscriuoptiopn yoru account has access to
az account list --output table
If you need to change the default subscription you can do so with
az account set --subscription <name of subscription>
Now we are at a place where we can start to do things.
Getting Started with Azure Commands
You can always list out all the azure command by using “az”. One that you will be using a lot is