remote run FileShare mount command result in disconnected state

Wang, Jane 61 Reputation points
2021-05-14T00:36:05.827+00:00

We followed Invoke-Command -ComputerName COMPUTER -ScriptBlock {​​​ COMMAND }​​​ -credential USERNAME
and run remotely against Azure Linux VM from script. The script looks like the following

az vm run-command invoke --command-id RunPowerShellScript --name test-vm -g omms-pep-daily \
--scripts 'param([string]$storageAccessKey)' \
'$resourceGroupName = <Resource Group Name>' \
'$storageAccountName = <Storage Account Name>' \
'$shareName = <File share name>' \
'Test-NetConnection -ComputerName "$storageAccountName.file.core.windows.net" -Port 445' \
'$accountKey = ConvertTo-SecureString -String <Storage Account Key> -AsPlainText -Force' \
'$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "Azure\$storageAccountName", $accountKey' \
'New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\$storageAccountName.file.core.windows.net\$shareName" -Credential $credential -Persist -Scope Global'

This mounted the fileshare in a discounted state. On the other hand, we do not have the access to run the script from within the Linux VM, although running from the VM directly works.

Is there a way to mount FileShare onto VM remotely, using the extension cmd, or any other way?

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,228 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,585 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 45,416 Reputation points Microsoft Employee
    2021-05-24T14:31:08.463+00:00

    @Wang, Jane Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.

    If the issue still persists, I would recommended refer this Troubleshoot Azure Files problems in Linux (SMB) (This article lists common problems that are related to Azure Files when you connect from Linux clients. It also provides possible causes and resolutions for these problems)

    If the issue still persists, Please share the screen shot of the error message.

    How to mount an NFS file share

    Use Azure Files with Linux

    Hope this helps!

    Kindly let us know if the above helps or you need further assistance on this issue.

    -------------------------------------------------------------------------------------------------------------------------------------

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments