Ubuntu-for-Azure-Developers

Setting up your Ubuntu 20.04 developer environment to build Azure solutions

This project is maintained by gloveboxes

1. Ubuntu 18.04 for Azure Developers

Ubuntu for Azure Developers

Author Dave Glover, Microsoft Australia
Platform Ubuntu 18.04 for Azure Developers, Kubuntu 18.04 for Azure Developers, Ubuntu 16.04 for Azure Developers
Date As at Feb 2019

This guide assumes you have some experience with Linux and you will open Terminal and Ctrl-Shift-V to paste in Bash commands.

Feel free to contribute to this guide.

Installing the Essentials

Visual Studio Code

Visual Studio Code is a must have IDE, open source, extensible, great language, debugging and tooling support.

Head to Visual Studio Code and download the .deb file for Debian and Ubuntu then install with QApt Package Installer.

1.1.2. Visual Studio Extensions

There are a stack of great extensions for Visual Studio Code. These are the ones that I find most useful.

  1. Azure Account, Azure Functions, Azure CLI Tools, Azure Event Hub Explorer, Azure Cosmos DB, Azure IoT Edge, Azure IoT Toolkit, SQL Server, C#, Docker, Python, C/C++, JSON Tools, JSON Escaper, Powershell, Azure Application Insights, Azure App Services, Arduino, Azure Resource Manager Tools, Azure Storage, Tools for AI, Markdown TOC, Code Spell Checker, Docker, Docs Authoring Pack, and more…

1.1.3. GitHub Client

When you start Visual Studio Code for the first time you’ll be prompted to install the GitHub client.

sudo apt install git

Before you can commit any changes against GitHub you’ll need to configure who you are.

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

If you are using GitHub two-factor authentication then you’ll need to create a GitHub token that you need to store securely. See Creating a personal access token for the command line for more information. You’ll need to use this token in place of your password when pushing changes to GitHub.

Check out Caching your GitHub password in Git to cache your GitHub credentials so you won’t be asked for your credentials every time you push/sync you repository.

In summary you need to run the following commands. Personally I use a much bigger number than 3600.

git config --global credential.helper 'cache --timeout=3600'

If you are using Visual Studio Team Services then checkout Use Git Credential Managers to Authenticate to VSTS

1.1.4. Installing the latest .NET Core SDK

  1. Install the latest release of the .NET Core SDK

  2. Confirm successful installation of .NET Core SDK

dotnet --version

1.1.5. Azure Storage Explorer

sudo snap install storage-explorer

1.1.6. Azure Storage Emulator

Install Azurite, a lightweight server clone of Azure Blob, Queue, and Table Storage that simulates most of the commands supported by it with minimal dependencies.

Notes.

1.1.7. Azure CLI (Command Line Interface)

Be sure that ‘curl’ is installed.

sudo apt install curl

Install Azure CLI 2.0 with apt

1.2. Azure Functions with Visual Studio Code

Code and test Azure Functions locally

Azure Functions Core Tools (note updated instructions for Ubuntu 18.04)

1.2.1. Install Azure Functions Core Tools

As at August 2018 see Install the Azure Functions Core Tools

cd ~/Downloads && \
sudo apt install curl -y

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update

sudo apt-get install azure-functions-core-tools

1.3. Toolkit

1.3.1. Docker

sudo apt update

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

sudo apt update

sudo apt install -y docker-ce && \
sudo systemctl status docker

It’s useful to add your user sudo rights to Docker. Note, you’ll need to restart your system for this setting to take effect.

sudo usermod -aG docker $USER

Notes.

Installing Node.js v10.x:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Notes.

1.3.2. Installing Anaconda Distribution 5

It is a free, easy-to-install package manager, environment manager and Python distribution with a collection of 1,000+ open source packages with free community support. Anaconda is platform-agnostic, so you can use it whether you are on Windows, macOS or Linux.

Installing Anaconda on Linux

Create an Anaconda Navigator Desktop Resource

mkdir -p ~/.local/share/applications && \
cat > ~/.local/share/applications/anaconda-navigator.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Anaconda
Exec=/home/dave/anaconda3/bin/anaconda-navigator
Icon=/home/dave/anaconda3/lib/python3.6/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
Terminal=false
Type=Application
Categories=Development;
EOL

Notes.

  1. Anaconda Cheat Sheet
  2. How to check your Anaconda version and updating
  3. Stop Installing Tensorflow using pip for performance sake!

1.3.3. Tensorflow

1.3.3.1. Python Support

If you want Tensorflow with GPU support for use with Python then by far the easiest way to install is with Anaconda as it will install the complete CUDA toolkit and cuDNN library into your selected environment. But note, this is community supported, and not officially supported.

  1. Create the Anaconda environment

    This would create a Anaconda environment with tensorflow-gpu support (requires an tensorflow capable nVida GPU, alternatively specify tersorflow-cpu), targeting Python 3.5, plus adds pylint useful in Visual Studio Code, and Jupyter Notebook support.

     conda create -n <envName> python=3.5 tensorflow-gpu pylint scipy jupyter requests scikit-learn
    
  2. Activate the Anaconda environment

    Activate the Anaconda environment

     source activate <envName>
    
  3. Deactivate an Anaconda Environment

     source deactivate
    

    Anaconda Navigator is the easiest way to manage Anaconda environments and launch environments.

     anaconda-navigator
    
  4. Create your Python Project, open it with Visual Studio Code add a python file and select the Tensorflow environment you just created.

1.3.3.2. Installing locally with nVidia GPU support

See

  1. Installing Tensorflow GPU on Ubuntu 18.04 LTS
  2. Installing Tensorlow, using pip in Anaconda
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.1-cp35-cp35m-linux_x86_64.whl pylint scipy

1.3.3.3. NVIDIA Container Runtime for Docker

If your PC has a nVidia GPU and you want to developer with Docker and TensorFlow-GPU support. Simpler than installing CUDA Driver and Toolkit on to local system.

Notes.

  1. Using TensorFlow via Docker
  2. NVIDIA Container Runtime for Docker

1.3.4. Microsoft Cognitive Toolkit

For information on setting up CNTK Docker Containers.

1.3.4.1. With nVidia CPU Support

  1. Ensure the NVIDIA Container Runtime for Docker is installed.

     nvidia-docker run -d -p 8888:8888 --name cntk-jupyter-notebooks -t microsoft/cntk
    
  2. Start Jupyter Notebook server in your Docker container:

     docker exec -it cntk-jupyter-notebooks bash -c "source /cntk/activate-cntk && jupyter-notebook --no-browser --port=8888 --ip=0.0.0.0 --notebook-dir=/cntk/Tutorials --allow-root"
    

1.3.5. Postman

Install library dependency

sudo apt install libgconf-2-4

Download and Install Postman

cd ~/Downloads && \
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz && \
sudo tar -xzf postman.tar.gz -C /opt && \
rm postman.tar.gz && \
sudo ln -s /opt/Postman/app/Postman /usr/bin/postman

Create Postman Desktop Resource

cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/opt/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
EOL

Notes.

1.3.6. Fiddler

See Use Fiddler in Ubuntu

1.3.7. VirtualBox

sudo apt-get install virtualbox

1.4. Internet of Things

1.4.1. Azure IoT Hub Explorer

Microsoft Azure IoT extension for Azure CLI

az extension add --name azure-iot

az iot Command Guide

Example IoT Hub command

az iot hub monitor-events --hub-name IotHubName

Notes.

1.4.2. Azure IoT Edge

1.4.2.1. Building ARM Docker Images from an x64 Ubuntu Host

If you are targeting ARM for your Docker builds then you will need to run the following command before you do your Docker build.

docker run --rm --privileged multiarch/qemu-user-static:register --reset

Notes.

1.5. Microsoft SQL Server for Linux

1.5.1. Microsoft SQL Server for Linux (Dockerised)

Install SQL Server and create a database on Ubuntu

Note, deleting a Microsoft SQL Server Docker container will also delete its data. So docker run to download and create and run the docker SQL Container and then use docker stop and start to control.

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
-p 1433:1433 --name sql1 \
-d microsoft/mssql-server-linux:2017-latest

To stop the Microsoft SQL Server Docker container.

docker stop sql1

To start the Microsoft SQL Server Docker container.

docker start sql1

Notes.

1.5.2. Microsoft SQL Server Operations Studio

Follow the notes for Installing Microsoft SQL Operations Studio

1.5.3. Microsoft SQL Server Extension for Visual Studio Code

Use Visual Studio Code to create and run Transact-SQL scripts for SQL Server

1.6. Embedded Development

1.6.1. Arduino

Download the Arduino IDE

1.6.2. Fritzing

Download from Fritzing Download Site.

I install in to a non system directory as Fritzing will complain that it doesn’t have access rights to create parts bins.

cd ~/Downloads && \
mkdir -p ~/Apps && \
tar -C $_ -xvjf fritzing-0.9.3b.linux.AMD64.tar.bz2 && \
sudo ln -s ~/Apps/fritzing-0.9.3b.linux.AMD64/Fritzing /usr/bin/fritzing

Create Fritzing Desktop Resource file

cat > ~/.local/share/applications/fritzing.desktop <<EOL
[Desktop Entry]
Version=0.9.3b
Name=Fritzing
GenericName=Fritzing
Comment=Electronic Design Automation software
Exec=fritzing 
Icon=/home/dave/Apps/fritzing-0.9.3b.linux.AMD64/icons/fritzing_icon.png
Terminal=false
Type=Application
Categories=Development;IDE;Electronics;EDA;
X-SuSE-translate=false
StartupNotify=true
Categories=PCB;
MimeType=application/x-fritzing-fz;application/x-fritzing-fzz;application/x-fritzing-fzp;application/x-fritzing-fzpz;application/x-fritzing-fzb;application/x-fritzing-fzbz;application/x-fritzing-fzm;
EOL

1.7. Samples

1.7.1. Azure IoT Edge Samples

Hands-on Grove Starter Kit for Azure IoT Edge

1.7.2. Debugging .NET Core apps in Docker Containers from Visual Studio Code on Linux

This is a sample that demonstrates how to use vscode to build and debug dotnet core 2.0 console application in docker container

Useful Utilities

grub customiser

How to Install Grub Customizer

Onedrive Support

How To Mount OneDrive In Linux Using Rclone

Windows 10 Stick Notes on the Web

Access Windows 10 Stick Notes via your browser - very handy for casual note taking

Install The New Ubuntu Community Theme “Yaru”

Gnome Tweak Tool

Todo after installing Ubuntu 18.04