Powershell: New-PSDrive no longer working in Cloud Shell

Created on 5 Feb 2019  路  23Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Basic steps:

  • Go to an existing Azure Storage File Share
  • Click the ellipsis at the far right of the Share Name -> Connect
  • Copy the code
  • Start a Cloud Shell session in the Azure portal
  • Paste the code from above and run it

NB: the 3 powershell commands are:

ConvertTo-SecureString
New-Object System.Management.Automation.PSCredential
New-PSDrive

When I execute the first 2 lines separately I don't get an error. It's only the last line.

Expected behavior

A new drive is created.
I should be able to type:

CD z:

(or whatever letter I pick instead of Z)

Actual behavior

Red error message:

New-PSDrive : The specified drive root "\\<my storage account>.file.core.windows.net\clouddrive" either does not exist, or it is not a folder.

Environment data

Name                           Value
----                           -----
PSVersion                      6.1.2
PSEdition                      Core
GitCommitId                    6.1.2
OS                             Linux 4.15.0-1036-azure #38~16.04.1-Ubuntu SMP Fri Dec 7 03:21:52 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

History

This trick has worked in the past. I was using it regularly about 12 months ago. At some point it stopped working, and the code auto-generated by the Azure Portal now errors :-/

Issue-Question Resolution-Answered

Most helpful comment

@jn-altius around last year July, the cloudshell backend os was switched to Linux from Windows. That change may impact the software behavior by mounting to azure storage file share. Previously in Windows, we used instructions here for mounting to Azure. That's why it worked for you new-psdrive. On Linux, our backend code mounted the user's storage account file share to $HOME/clouddrive already (you can run df -k . If want to use new-psdrive, you may try the following example:

PS Azure:\> New-PSDrive -Name z -Root /home/jianyun/clouddrive -PSProvider filesystem

Name           Used (GB)     Free (GB) Provider      Root                                                                                   CurrentLocation
----           ---------     --------- --------      ----                                                                                   ---------------
z                   5.20          0.80 FileSystem    /home/jianyun/clouddrive

PS Azure:\> cd z:
PS z:/>

If you want to view mount details, you may run df -k.

All 23 comments

/cc @SteveL-MSFT

cc @edyoung who owns CloudShell

@jn-altius around last year July, the cloudshell backend os was switched to Linux from Windows. That change may impact the software behavior by mounting to azure storage file share. Previously in Windows, we used instructions here for mounting to Azure. That's why it worked for you new-psdrive. On Linux, our backend code mounted the user's storage account file share to $HOME/clouddrive already (you can run df -k . If want to use new-psdrive, you may try the following example:

PS Azure:\> New-PSDrive -Name z -Root /home/jianyun/clouddrive -PSProvider filesystem

Name           Used (GB)     Free (GB) Provider      Root                                                                                   CurrentLocation
----           ---------     --------- --------      ----                                                                                   ---------------
z                   5.20          0.80 FileSystem    /home/jianyun/clouddrive

PS Azure:\> cd z:
PS z:/>

If you want to view mount details, you may run df -k.

Why was this closed?

The bug I reported has not been mentioned. Or a fix or workaround given.

The bug I describe is when you go to Connect in the context menu for a File Share. The auto generated code is wrong.

Will this be fixed? Or just left as it is?

@jn-altius The repo is for PowerShell Core only and it is not right place where the issue should be tracked. I hope MSFT team will share more info for you.
Thanks for your report!

Can you give me a clue _where_ it should be raised then? Do you have the URL for the File Storage or Cloud Shell repo?

Cheers

I am sure MSFT members help you. Please wait.

@jianyunt Your code example does not work :-(

Did you test that in on-premise PowerShell, or Cloud Shell?

The only difference I can see between your code and the auto-generated code is the direction of the slashes in the -Root

Here is my code, amended to match yours:
````powershell
$acctKey = ConvertTo-SecureString -String "" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "Azure\hrxaconfigstored", $acctKey
New-PSDrive -Name Z -PSProvider FileSystem -Root "//hrxaconfigstored.file.core.windows.net/clouddrive" -Credential $credential

````

The above code still returns the message "The specified drive root either does not exist or is not a folder".

Is New-PSDrive irreparably broken in Cloud Shell now?

I closed it because it looked like @jianyunt had addressed your concern. Since that isn't working for you, I'll reopen it.

@jn-altius this might be the Azure portal issue. I just chatted with the portal team, they ask you to open an support ticket via https://ms.portal.azure.com -> ? -> Help +Support and then "New Support Request"
image

I ran my sample on cloudshell,

New-PSDrive -Name z -Root $HOME/clouddrive -PSProvider filesystem

How did you pass Credentials?

no. Are you running it in on-prem machines?

According to https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows#prerequisites, it needs to make sure port open 445

No, not using any machine at all. I'm using Cloud Shell in the portal:
https://shell.azure.com

Please try on your local machines.
On cloudshell, we cannot mount to any personal Azure file shares through new-psdrive after we switched to Linux based container, except the one cloudshell is using (you can view it df -k). This is most likely the user you logged on to cloudshell is regular user not sudo (disabled), unlike Windows-based container we used to use on cloudshell which was administrator.

I can't use a local machine. The solution I am building is PaaS-only; there are no IaaS components.

So are you saying that as of July last year that the ability to mount a drive in Cloud Shell has been removed from Azure?

correct.

That is disappointing :-(

Will this facility be returned in a future release of Cloud Shell?

looping in @HemantMahawar @maertendMSFT for the above question.

Unfortunately, sudo is not currently supported in Cloud Shell and it is not currently planned. It would be best to submit a feature request at https://aka.ms/cloudshell/feedback so that the request can be tracked and voted upon by other users.

Is there something we need to track and fix in _this repo_ or we can close the issue?

It's not a powershell bug, so makes sense to close here. MaertendMSFT gave the correct feedback link

@maertendMSFT Thanks for the link. I have requested the return of this feature.

Meanwhile Azure is still giving out duff code (click the ellipsis on a File Share and then connect -> the code produced is a dud). Who is it that needs to be notified about that?

Was this page helpful?
0 / 5 - 0 ratings