How to capture entire interactive session output in Azure Cloud Shell

Radhakrishna MV 66 Reputation points
2020-07-21T17:26:05.15+00:00

I tried the history command to get the list of all commands typed by me in the bash mode of Azure Cloud Shell.

I need the output of all Azure CLI commands that I type to be logged as well so that I can download the entire interactive session as a text file for review later

If this is possible, how can it be achieved?

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
651 questions
0 comments No comments
{count} votes

Accepted answer
  1. vipullag-MSFT 24,711 Reputation points
    2020-07-23T06:27:14.863+00:00

    @anilmv

    As the Cloud Shell is similar to the bash shell, you can use similar bash supported commands.

    For your ask, you can try 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.

    Below is the screenshot for your reference. Hope this helps.

    Record session:

    13416-record-session.jpg

    View Recorded Session:

    13432-view-record-session.jpg

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. KarishmaTiwari-MSFT 18,627 Reputation points Microsoft Employee
    2020-07-22T01:22:46.947+00:00

    Cloud Shell utilizes Azure File storage to persist files across sessions. On initial start, Cloud Shell prompts you to associate a new or existing file share to persist files across sessions.

    Once you have a file share associated, you can Click the upload/download files icon on the top left of the window, then select upload or download.
    For downloading file, enter the fully qualified file path into the pop-up window (i.e., basically a path under the /home/user directory which shows up by default), and select the "Download" button.
    Details provided here with screenshots: https://learn.microsoft.com/en-us/azure/cloud-shell/using-the-shell-window#upload-and-download-files

    Note: Files and file paths are case sensitive in Cloud Shell. Double check your casing in your file path.

    You can also go to the mounted file share, select the target file and click on the Download button.
    Details provided here: https://learn.microsoft.com/en-us/azure/cloud-shell/persisting-shell-storage#transfer-local-files-to-cloud-shell

    More information on Persisting files in Azure Cloud Shell:
    https://learn.microsoft.com/en-us/azure/cloud-shell/using-the-shell-window#upload-and-download-files