Setting up Python3 and MS Azure CLI on your MacOS
Introduction
Getting started with MS Azure cloud based projects as a solutions architect there are numerous tools accessible to help with managing Azure cloud resources. The Azure command-line interface (CLI) is Microsoft's cross-platform command-line experience. Use it in your browser with Azure Cloud Shell, or install it on macOS for local access from the terminal command window.
The Azure CLI [v2.0.58 as of 02.2018] is easy to work with, and best used for building automation scripts that work with the relevant Azure Resource Manager. It is designed to make scripting easy, query data, support long-running operations, and so on...
Following are the details of the prerequisite commands needed to be executed to ensure that the latest stable version of Python [v3.7.2 as of 02.2018] is installed and the relevant entry into your PATH environment variable.
If you don't already know, Python is an interpreted scripting language and it is used to write large commercial applications like Google's search engine, YouTube, and the web-oriented transaction system of the New York Stock Exchange (NYSE). Python can also be used to process text, display numbers or images, solve scientific equations, and save data. In short, it is used behind the scenes to process a lot of elements you might need or encounter on mobile devices. Another awesome example is Python SciPy which is major component of machine learning and data science algorithms. Kudos to Guido van Rossum the dutch programmer who was author of python programming language.
You do not need to install or configure anything else to use Python 2 as it comes default out of the box with MacOS doc. Python 2 that ships with OS X is great for learning, but it’s not good for development. The version shipped with OS X may be out of date from the official current Python release, which is considered the stable production version.
Steps to the bits and bobs
Let’s install the latest stable version of Python.
Before installing Python, you’ll need to install GCC. GCC can be obtained by downloading Xcode, the smaller Command Line Tools (must have an Apple account) or the even smaller OSX-GCC-Installer package.
If you perform a fresh install of Xcode, you will also need to execute install of commandline tools by running xcode-select --install on the terminal.
If this has been installed already you should see the following error: "command line tools are already installed,"..... see below
While OS X comes with a large number of Unix utilities, those familiar with Linux systems will notice one key component missing: a package manager. Homebrew fills this gap and strongly recommend using this package manager to manage all dependencies going forward. Guaranteed to make your life (note***your coding life) a lot simpler.
To install Homebrew, open Terminal or your favourite OS X terminal emulator and run
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The script will explain what changes it will make and prompt you before the installation begins. Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable.
You can do this by adding the following line at the bottom of your ~/.profile file
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Now, to install Python 3 execute the following command
brew install python3
This will take a minute or two.
Pip
Homebrew installs pip pointing to the Homebrew’d Python 3 for you.
Working with Python 3
At this point, you have the system Python 2.7 available, the Homebrew version of Python 2 installed, and the Homebrew version of Python 3 as well.
will launch the Homebrew-installed Python 3 interpreter.
$ python
will launch the Homebrew-installed Python 2 interpreter (if any).
$ python 2
will launch the Homebrew-installed Python 3 interpreter.
$ python 3
If the Homebrew version of Python 2 is installed then pip2 will point to Python 2. If the Homebrew version of Python 3 is installed then pip will point to Python 3.
The rest of the guide will assume that python references Python 3.
# Do I have a Python 3 installed?
$ python --version
Python 3.7.2 # Success!
If all of the above commands was executed and installed successfully then the above should return Python 3.7.2 from terminal command.
Now to Install Azure CLI 2.0 on macOS
Within the Terminal, run the following command to install Azure CLI 2.0 with a single command:
curl -L https://aka.ms/InstallAzureCli
When prompted with “In what directory would you like to place the ‘az’ executable?” you can just hit Return on your keyboard (aka leave it blank) and it’ll install it within “/Users/{username}/bin“.
Just sit back and relax while it gets busy installing…
Once completed run the command
$ az login
A browser window pop up prompting you to login to Azure cloud platform is instantiated.
Therefore, If you then see something like above screenshot then you are good to go with MS Azure CLI commands and local shell.
Keeping it simple! :)
Creating VM can be easily achieved using MS Azure CLI commands