Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Customize Azure Cloud Shell Bash Environment

- 24 Sep 2021

I wanted to customize my Azure Cloud Shell Bash Environment to set the active subscription and define bash aliases at start up.  I could not find a good reference so here is how to do some simple things.

Bash file structure in Azure Cloud Shell

When your start the Cloud Shell it will prompt you to create an Azure Storage to persist state.  After that the /home directory will have the files you place in it.  Doing ls – all will show you the hidden files:

image

Inspecting .bashrc with code (type code .bashrc) I saw I could add a file .bash_aliases and it would be read on startup if it exists:

image

at first I created the file “.bash_aliases” and put my alias in there but decided instead to follow this pattern and create a file startup.sh to add some other commands to execute at startup.  I added the lines you see above:

if [ -f ~/startup.sh ]; then
     . ~/startup.sh
fi

and then created and edited a file “startup.sh”:

image

Closing and starting the Azure Cloud Shell now runs this and sets up my environment the way I want!

image

<< Go Back