今天偶尔发现有个小问题,打开cloud shell的时候发现有以下提示,开始时候没怎么注意,之后发现关掉cloud shell之后,之前保存的文件都找不到了,回想起来应该是和这个提示有关系

解决Cloud Shell mount问题_云计算

cloud shell本身的持久化存储是用Azure File来实现的,用户数据会被统一上传到一个img文件里,出现这个问题的原因估计是之前清理不需要的资源时,不小心把这个fileshare也清理了,从Bash和PowerShell相关的提示里可以看到之前是mount到一个叫static的storage account下的,这个storage account已经被清理掉了,导致出现了上边的报错

解决Cloud Shell mount问题_shell_02

解决Cloud Shell mount问题_PowerShell_03

从页面上找了找也没看到在哪能重新配置的,搜了搜之后,发现可以用命令手动重建mount关系,首先可以先把storage account和file share建好

注意storage account的region是有一定要求的

Area

Region

Americas

East US, South Central US, West US

Europe

North Europe, West Europe

Asia Pacific

India Central, Southeast Asia


az storage account create \
    --name azcloudshell$RANDOM \
    --resource-group CloudShell \
    --location SoutheastAsia \
    --sku Standard_LRS \
    --kind StorageV2 

解决Cloud Shell mount问题_azure_04

列出key

STORAGEKEY=$(az storage account keys list \
    --resource-group CloudShell \
    --account-name azcloudshell \
    --query "[0].value" | tr -d '"')

解决Cloud Shell mount问题_PowerShell_05

创建fileshare

az storage share create \
--account-name azcloudshell \
--account-key $STORAGEKEY \
--name cloudshell

解决Cloud Shell mount问题_cloud_06

接下来通过命令把cloudshell mount到fileshare

clouddrive mount -s $sid -g CloudShell -n azcloudshell -f cloudshell

解决Cloud Shell mount问题_云计算_07

或者是用个更简单的办法,直接先umount,然后系统会自动提示你需要mount一个新的fileshare

clouddrive unmount

解决Cloud Shell mount问题_PowerShell_08