Persist files in Azure Cloud Shell

Cloud Shell utilizes Azure File storage to persist files across sessions.

Set up a clouddrive file share

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


Bash and PowerShell share the same file share. Only one file share can be associated with automatic mounting in Cloud Shell.

Create new storage

When you use basic settings and select only a subscription, Cloud Shell creates three resources on your behalf in the supported region that's nearest to you:

  • Resource group: cloud-shell-storage-<region>
  • Storage account: cs<uniqueGuid>
  • File share: cs-<user>-<domain>-com-<uniqueGuid>

The Subscription setting

The file share mounts as clouddrive in your $Home directory. This is a one-time action, and the file share mounts automatically in subsequent sessions.

In Bash, the file share also contains a 5-GB image that is created for you which automatically persists data in your $Home directory.

Use existing resources

By using the advanced option, you can associate existing resources. When the storage setup prompt appears, select Show advanced settings to view additional options. The drop-down menus are filtered for your assigned Cloud Shell region and the locally redundant storage and geo-redundant storage accounts.

In Bash, existing file shares receive a 5-GB image created for you to persist your $Home directory.

The Resource group setting

Restrict resource creation with an Azure resource policy

Storage accounts that you create in Cloud Shell are tagged with ms-resource-usage:azure-cloud-shell. If you want to disallow users from creating storage accounts in Cloud Shell, create an Azure resource policy for tags that are triggered by this specific tag.

Supported storage regions

Associated Azure storage accounts must reside in the same region as the Cloud Shell machine that you're mounting them to.

To find your assigned region you may:

  • View the note on the "Advanced storage settings" dialog
  • Refer to the name of the storage account created for you (ex: cloud-shell-storage-westus)
  • Run env and locate the variable ACC_LOCATION

Cloud Shell machine exist in the following regions:

Area Region
Americas East US, South Central US, West US
Europe North Europe, West Europe
Asia Pacific India Central, Southeast Asia

Come funziona l'archiviazione di Bash in Cloud ShellHow Bash in Cloud Shell storage works

Bash in Cloud Shell rende persistenti i file tramite entrambi i metodi seguenti:Bash in Cloud Shell persists files through both of the following methods:

  • Creazione di un'immagine del disco della directory $Home per rendere persistenti tutti i contenuti della directory.Creating a disk image of your $Home directory to persist all contents within the directory. L'immagine del disco viene salvata nella condivisione file specificata come acc_<User>.img in<User>.img e le modifiche vengono automaticamente sincronizzate.The disk image is saved in your specified file share as acc_<User>.img at<User>.img, and it automatically syncs changes.
  • Montaggio della condivisione file specificata come clouddrive nella directory $Home per l'interazione diretta con la condivisione file.Mounting your specified file share as clouddrive in your $Home directory for direct file-share interaction. Viene eseguito il mapping di /Home/<User>/clouddrive a<User>/clouddrive is mapped to


Tutti i file della directory $Home, come le chiavi SSH, vengono mantenuti nell'immagine del disco utente archiviata nella condivisione file montata.All files in your $Home directory, such as SSH keys, are persisted in your user disk image, which is stored in your mounted file share. Applicare le procedure consigliate quando si rendono persistenti le informazioni nella directory $Home e nella condivisione file montata.Apply best practices when you persist information in your $Home directory and mounted file share.

Usare il comando clouddriveUse the clouddrive command

Con Bash in Cloud Shell è possibile eseguire un comando denominato clouddrive, che consente di aggiornare manualmente la condivisione file montata in Cloud Shell.With Bash in Cloud Shell, you can run a command called clouddrive, which enables you to manually update the file share that is mounted to Cloud Shell. Esecuzione del comando "clouddrive"Running the "clouddrive" command

Montare una nuova clouddriveMount a new clouddrive

Prerequisiti per il montaggio manualePrerequisites for manual mounting

È possibile aggiornare la condivisione file associata a Cloud Shell usando il comando clouddrive mount.You can update the file share that's associated with Cloud Shell by using the clouddrive mount command.

Se si monta una condivisione file esistente, gli account di archiviazione devono avere le caratteristiche seguenti:If you mount an existing file share, the storage accounts must be:

  • Avere un account di archiviazione ridondante a livello locale o globale per supportare le condivisioni file.Locally redundant storage or geo-redundant storage to support file shares.
  • Trovarsi nell'area assegnata.Located in your assigned region. Durante l'onboarding, l'area a cui si è assegnati viene elencata nel nome del gruppo di risorse cloud-shell-storage-<region>.When you are onboarding, the region you are assigned to is listed in the resource group name cloud-shell-storage-<region>.

Il comando di montaggio clouddriveThe clouddrive mount command


Se si sta montando una nuova condivisione file, una nuova immagine utente viene creata per la directory $Home.If you're mounting a new file share, a new user image is created for your $Home directory. L’immagine $Home precedente viene mantenuta nella condivisione file precedente.Your previous $Home image is kept in your previous file share.

Eseguire il comando clouddrive mount con i parametri seguenti:Run the clouddrive mount command with the following parameters:

clouddrive mount -s mySubscription -g myRG -n storageAccountName -f fileShareName

Per visualizzare altri dettagli, eseguire clouddrive mount -h, come illustrato di seguito:To view more details, run clouddrive mount -h, as shown here:

Esecuzione del comando `clouddrive mount`

Smontare l'unità clouddriveUnmount clouddrive

È possibile smontare in qualsiasi momento una condivisione file montata in Cloud Shell.You can unmount a file share that's mounted to Cloud Shell at any time. Dal momento che Cloud Shell richiede l’uso di una condivisione file montata, verrà richiesto di creare e montare una nuova condivisione file alla sessione successiva.Since Cloud Shell requires a mounted file share to be used, you will be prompted to create and mount another file share on the next session.

  1. Eseguire clouddrive unmount.Run clouddrive unmount.
  2. Accettare e confermare i prompt.Acknowledge and confirm prompts.

La condivisione file continuerà a esistere a meno che non venga eliminata manualmente.Your file share will continue to exist unless you delete it manually. Cloud Shell non eseguirà più la ricerca di questa condivisione file nelle sessioni successive.Cloud Shell will no longer search for this file share on subsequent sessions. Per visualizzare altri dettagli, eseguire clouddrive unmount -h, come illustrato di seguito:To view more details, run clouddrive unmount -h, as shown here:

Esecuzione del comando "clouddrive unmount"


Sebbene l'esecuzione di questo comando non elimini le risorse, l'eliminazione manuale di un gruppo di risorse, un account di archiviazione o una condivisione file di cui è stato eseguito il mapping a Cloud Shell cancellerà l'immagine del disco della directory $Home e tutti i file presenti nella condivisione file.Although running this command will not delete any resources, manually deleting a resource group, storage account, or file share that's mapped to Cloud Shell will erase your $Home directory disk image and any files in your file share. Questa azione non può essere annullata.This action cannot be undone.

Elenco clouddriveList clouddrive

Per sapere quale condivisione file è montata come clouddrive, eseguire il comando df.To discover which file share is mounted as clouddrive, run the df command.

Il percorso file a clouddrive indicherà il nome dell'account di archiviazione e la condivisione file nell'URL.The file path to clouddrive will show your storage account name and file share in the URL. Ad esempio, // example, //

justin@Azure:~$ df
Filesystem                                          1K-blocks   Used  Available Use% Mounted on
overlay                                             29711408 5577940   24117084  19% /
tmpfs                                                 986716       0     986716   0% /dev
tmpfs                                                 986716       0     986716   0% /sys/fs/cgroup
/dev/sda1                                           29711408 5577940   24117084  19% /etc/hosts
shm                                                    65536       0      65536   0% /dev/shm
// 5368709120    64 5368709056   1% /home/justin/clouddrive

Transfer local files to Cloud Shell

The clouddrive directory syncs with the Azure portal storage blade. Use this blade to transfer local files to or from your file share. Updating files from within Cloud Shell is reflected in the file storage GUI when you refresh the blade.

Download files

List of local files

  1. In the Azure portal, go to the mounted file share.
  2. Select the target file.
  3. Select the Download button.

Upload files

Local files to be uploaded

  1. Go to your mounted file share.
  2. Select the Upload button.
  3. Select the file or files that you want to upload.
  4. Confirm the upload.

You should now see the files that are accessible in your clouddrive directory in Cloud Shell.

Passaggi successiviNext steps

Avvio rapido di Bash in Cloud ShellBash in Cloud Shell Quickstart
Informazioni sull'archiviazione di Microsoft Azure Files Learn about Microsoft Azure Files storage
Informazioni sui tag di archiviazione Learn about storage tags