Answered by:
Unable to permanently mount azure files to a azure windows VM

Question
-
I am trying to have a persistent file mount to azure files storage. I follow the docs by issuing the following:
$resourceGroupName = "<your-resource-group-name>"
$storageAccountName = "<your-storage-account-name>"
# These commands require you to be logged into your Azure account, run Login-AzureRmAccount if you haven't
# already logged in.
$storageAccount = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName
$storageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName
# The cmdkey utility is a command-line (rather than PowerShell) tool. We use Invoke-Expression to allow us to
# consume the appropriate values from the storage account variables. The value given to the add parameter of the
# cmdkey utility is the host address for the storage account, <storage-account>.file.core.windows.net for Azure
# Public Regions. $storageAccount.Context.FileEndpoint is used because non-Public Azure regions, such as sovereign
# clouds or Azure Stack deployments, will have different hosts for Azure file shares (and other storage resources).
Invoke-Expression -Command "cmdkey /add:$([System.Uri]::new($storageAccount.Context.FileEndPoint).Host) " + `
"/user:AZURE\$($storageAccount.StorageAccountName) /pass:$($storageAccountKeys[0].Value)"replacing my resource group name and my storage account name. When I execute it in PowerShell, I get the following response:
Invoke-Expression : A positional parameter cannot be found that accepts argument '+'.
At line:14 char:1
+ Invoke-Expression -Command "cmdkey /add:$([System.Uri]::new($storageA ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommandAny ideas?
Mitch
Tuesday, October 23, 2018 4:57 PM
Answers
-
Hey Mitch, I did some troubleshooting to the command, and I was able to fix the issue by using the bellow command
Invoke-Expression -Command "cmdkey /add:$([System.Uri]::new($storageAccount.Context.FileEndPoint).Host) /user:AZURE\$($storageAccount.StorageAccountName) /pass:$($storageAccountKeys[0].Value)"
Results:
CMDKEY: Credential added successfully.
PS C:\Users\adm>Let me know if this helps so I can notify the product team of the bug.
- Proposed as answer by Adam Smith (Azure) Tuesday, October 23, 2018 8:28 PM
- Marked as answer by mjw913 Tuesday, October 23, 2018 9:31 PM
Tuesday, October 23, 2018 8:28 PM
All replies
-
Hey Mitch, I did some troubleshooting to the command, and I was able to fix the issue by using the bellow command
Invoke-Expression -Command "cmdkey /add:$([System.Uri]::new($storageAccount.Context.FileEndPoint).Host) /user:AZURE\$($storageAccount.StorageAccountName) /pass:$($storageAccountKeys[0].Value)"
Results:
CMDKEY: Credential added successfully.
PS C:\Users\adm>Let me know if this helps so I can notify the product team of the bug.
- Proposed as answer by Adam Smith (Azure) Tuesday, October 23, 2018 8:28 PM
- Marked as answer by mjw913 Tuesday, October 23, 2018 9:31 PM
Tuesday, October 23, 2018 8:28 PM -
This fixed it.
You may want to update the docs at https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows
Mitch
Tuesday, October 23, 2018 9:31 PM -
Already submitted a change to the team :) Glad it helped.Tuesday, October 23, 2018 9:40 PM
-
Adam,
I am still having issues. going further down in the doc, it describes how to mount the cloud storage. That works great, however when I reboot the server, it does not re-appear. Is this supposed to automatically remount the cloud storage? If not, is there another way to do that? the idea is I will have a number of IaaS Windows servers that need access to the files and they need the ability of being shut down and re-started and still have access upon restart.
Mitch
Thursday, October 25, 2018 8:22 PM