2
votes

I'm not proficient in Powershell yet, so please bear with me if I use the incorrect terminology.(And please correct me if I do.)

I have installed the Az and Azure.Storage modules.

I have also connected to my account using Connect-AZAccount (Is this the best way? Since you need to copy the URL and login via a browser)

Then I was just trying to view the files, to test the connection. Using Get-AzureStorageFile

This prompts me for a sharename - I used the name of the folder under File Shares in Azure Storage Explorer. But this failed, see failure below

cmdlet Get-AzureStorageFile at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) ShareName: bss get-azurestoragefile : Could not get the storage context. Please pass in a storage context or set the current storage context.

Additional information to note, I do not have access to the Account Key, only the SAS Token.

Any help would be appreciated.

1

1 Answers

1
votes

If you use Connect-AzAccount, you will use the Az module powershell Get-AzStorageFile instead of Get-AzureStorageFile. Before running the Get-AzStorageFile command, you need to pass the storage context with New-AzStorageContext to fix the error.

Sample:

$context = New-AzStorageContext -StorageAccountName "<StorageAccountName>" -StorageAccountKey "<StorageAccountKey>"
Get-AzStorageFile -ShareName "<ShareName>" -Path "<ContosoWorkingFolder>" -Context $context