HOW TO capture entire interactive session output in Azure Cloud Shell
While trying out Azure CLI 2 commands, I liked the rich details that were shown as the command output.
I learnt that the history command gets the list of commands typed by me in the bash mode of Azure Cloud Shell but I couldn't figure how to capture the output of all Azure CLI commands that I typed. I was looking for a way that the command output could be logged so that I can download the entire interactive session as a text file for review later. I asked on Microsoft Q&A forum and got a wonderfully detailed answer
The trick is to use the script command to record your session. This will capture all your commands and output to a file you specify. However, you need to ensure you run the script command to start recording and exit once you want to end. If you want to append the commands to the same file use script -a filename to the same file name you specify.
To download the session recording file, use the Download file option from the Azure Cloud Shell menu -
Alternatively, at the Cloud Shell prompt, type download filename
The CLI offers an interactive mode that automatically displays help information and makes it easier to select sub-commands. You enter interactive mode with the az interactive command.
To get a full list of the available commands and full help information you can run the following command:
# Azure CLI 1.0
azure
# Azure CLI 2.0
az
I learnt that the history command gets the list of commands typed by me in the bash mode of Azure Cloud Shell but I couldn't figure how to capture the output of all Azure CLI commands that I typed. I was looking for a way that the command output could be logged so that I can download the entire interactive session as a text file for review later. I asked on Microsoft Q&A forum and got a wonderfully detailed answer
The trick is to use the script command to record your session. This will capture all your commands and output to a file you specify. However, you need to ensure you run the script command to start recording and exit once you want to end. If you want to append the commands to the same file use script -a filename to the same file name you specify.
To download the session recording file, use the Download file option from the Azure Cloud Shell menu -
The CLI offers an interactive mode that automatically displays help information and makes it easier to select sub-commands. You enter interactive mode with the az interactive command.
To get a full list of the available commands and full help information you can run the following command:
# Azure CLI 1.0
azure
# Azure CLI 2.0
az
Comments
Post a Comment