Home Making an Install Script - Part 1: What and Why
Post
Cancel

Making an Install Script - Part 1: What and Why

The Azure Developer CLI (azdev) gets a dev from code to cloud as quickly as possible. Our goal is to have a new developer with no prior Azure (or even cloud) experience type in a few console commands and deploy a working, scalable, and monitorable cloud application in a few minutes. This should work on any supported platform (Windows, Mac, Linux), and and be accomplishable in a minimal set of steps.

We think a process like this…

1
curl -fsSL https://aka.ms/install-azd.sh | bash

or this…

1
Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression

is easier to follow than a choose-your-own-adventure book of shell snippets tailored to each conceivable platform. Consider the (rightfully) complex install process for Kubernetes. In this example you have to pick your platform (mac/linux/windows) and for each of those scroll through an exhaustive list of potential install methods ranging from an install script that downloads a binary to the current folder or a series of steps needed to install using a package manager (adding keys, adding registry locations).

A user approaching our tool for the first time and needing to traverse a decision tree just to get started is more likely to abandon the process. Install scripts for tools like azd need to keep the user on task and productive.

The install scripts do a few things that we’ll get into in later posts:

  1. Figure out which binary to download
  2. Download the binary which is packaged in a .zip or .tar.gz file
  3. Copy the binary into a standard location (on Windows a per-user install by default)
  4. (On Windows) Add the install location to the user’s PATH (on Linux/MacOS the default install location is already in PATH)

We wrote scripts in bash and PowerShell so that our tool can be installed and ready to go in one step on most popular platforms and Azure Pipelines CI agents for those popular platforms.

Up next we’ll discuss how we built the installers, verify that they work, and integrated the whole process into our CI and release automation.

Finally, verify before running

When using in a production or other sensitive environment, ensure that the install script is coming from a reputable source. Our PowerShell install script is signed and downloadable securely from https://aka.ms/install-azd.ps1 or (unsigned) from our repository. Bash scripts do not have such signing/verification features built in. They can be downloaded securely from https://aka.ms/install-azd.sh or from our repository using git or https.