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?