azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Behaviour of Get-AzureStorageFile has changed from 0.9.8 -> 1.0.1

Open shiningdragon opened this issue 11 years ago • 4 comments

Im seeing a lot of differences in the behaviour of Get-AzureStorageFile in the new version when accessing sub directories of shares - its resulting in a lot of broken scripts

To repro try the following

$storageAccountName = "hamadatest"
$account = Get-AzureStorageAccount -StorageAccountName $storageAccountName -ErrorAction SilentlyContinue
if($account -eq $null)
{
    New-AzureStorageAccount -StorageAccountName $storageAccountName -Location 'North Europe'
}
# Create share
$storageKeys = Get-AzureStorageKey -StorageAccountName $storageAccountName
$storagePrimaryKey = $storageKeys.Primary
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storagePrimaryKey
$azureShare = New-AzureStorageShare 'share1' -Context $storageContext

# Create directories
New-AzureStorageDirectory -Share $azureShare -Path 'folder1'
New-AzureStorageDirectory -Share $azureShare -Path 'folder1\folder2'

$azureShare = Get-AzureStorageShare 'share1' -Context $storageContext

# In 0.9.8 the following command returns folder1 - in 1.0.1 it returns folder1
Get-AzureStorageFile -Share $azureShare -Path '' | where Name -EQ 'folder1'

# In 0.9.8 the following command returns **folder2** - in 1.0.1 it returns **folder1**
Get-AzureStorageFile -Share $azureShare -Path 'folder1' 

shiningdragon avatar Nov 11 '15 11:11 shiningdragon

Unable to list folder contents. any workaround?

AndreVX avatar Dec 22 '15 14:12 AndreVX

Check the bug #1543 there is a workaround

FabienLavocat avatar Feb 08 '16 19:02 FabienLavocat

@shiningdragon The cmdlet Get-AzureStorageFile should not only be able to list files/directories under a share/directory, but also be able to get instance and attributes of a single file or a directory. The old behavior only can do list, but is pain to get a single file's instance.

With current Get-AzureStorageFile, it can get a single instance of file/directory with Path parameter and list the share/directory if Path is not specified. To list a specific directory, you can first get the directory instance and then list it: $dir = Get-AzureStorageFile -ShareName 'sharename' -Path 'dirpath' -Context $ctx Get-AzureStorageFile -Directory $dir

EmmaZhu avatar Mar 24 '16 02:03 EmmaZhu

Feel free to reactivate the issue if the above suggestion does not address your questions.

vinjiang avatar Mar 30 '16 17:03 vinjiang