Cloud Shell, as the name suggests runs in the Cloud.
You cannot access files on your local machine using Cloud shell
Uploading file to Azure for use in Cloud Shell
Hello,
I am trying to get a VHD into Azure for use in creating a disk image that I can then use to create a VM. My script below works well from my local PC using Powershell to upload the VHD from a local directory but this does not work from Azure Cloud Shell.
Upload the VHD
New-AzResourceGroup -Name $resourceGroup -Location $location
New-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccount -Location $location -SkuName $storageType -Kind "Storage" $urlOfUploadedImageVhd = ('https://' + $storageaccount + '.blob.core.windows.net/' + $containername + '/' + $vhdName) Add-AzVhd -ResourceGroupName $resourceGroup -Destination $urlOfUploadedImageVhd
-LocalFilePath $localPath
Note: Uploading the VHD may take a while!
How can I upload the same VHD from from my local PC using Azure Cloud Shell using a Powershell Script?
Regards,
Abby
2 answers
Sort by: Most helpful
-
KalyanChanumolu-MSFT 8,336 Reputation points
2020-07-02T09:49:34.657+00:00 -
vipullag-MSFT 26,396 Reputation points
2020-07-20T10:32:17.967+00:00 Azure cloud shell is a browser based shell which is accessible from browser. Azure cloud shell does not have persistent storage (storage can be added using disk image or file share. More information can be found here.
When you are running any command in azure cloud shell, it does not have access to local file system and hence it can't upload local PC VHD image using azure cloud shell. Azure cloud shell is running inside compute instance hosted in azure and does not access any local file system.
Azure cloud shell provides persistence mechanism as cloud drive but you will need to upload files to cloud drive and then upload to blob storage which is same as uploading directly to blog storage.
However, you can try to upload the VHD to Azure using storage explorer and run the script from a Windows VM and point the uploaded VHD. Also, once the VHD is uploaded to blob from Cloud Shell while running the script point the VHD in he blob.