I am attempting to use the AzureRM PowerShell Module to generate a new SAS Token for a Blob Container (and subfolder data) at the command line. This process works when navigating in the Portal and manually creating the SAS Token for the specified file, but is failing when using PS
$SAResourceGroupName="someresourcegroupname"
$StorageAccountName="randomstorageaccountnamehere"
$StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
$Context=New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
$tmpStart = Get-Date
$tmpEnd = $tmpStart.AddHours(0.5)
$Starttime = ($tmpStart).ToString("yyyy-MM-ddTHH:mm:ssZ")
$EndTime = ($tmpEnd).ToString("yyyy-MM-ddTHH:mm:ssZ")
$SASToken = New-AzureStorageBlobSASToken -Blob $StorageAccountName -Container "ContainerNameHere/ToolsSubFolder/randomfile.ZIP" -Context $Context -Permission r -StartTime $StartTime -ExpiryTime $EndTime -FullURI
The resulting SAS Token that is being generated has the $StorageAccountName twice, and the formatting is being done in HTML, so the token itself doesnt have the correct characters.
(data scrubbed)
PS C:\Users\lsierra> New-AzureStorageBlobSASToken -Container "ContainerNameHere/ToolsSubFolder/randomfile.ZIP" -Blob $StorageAccountName -Permission r -Context $Context -FullUri https://randomstorageaccountnamehere.blob.core.windows.net/ContainerNameHere/ToolsSubFolder/randomfile.ZIP/randomstorageaccountnamehere?sv=2017-07-29&sr=b&sig=kXzYwqW%2BjKH1BAXwsBovVzCbGY2XzLxUY BxKQNkeqns%3D&se=2018-11-02T18%3A02%3A02Z&sp=r
If I navigate to the Portal and manually generate a new SAS Token, the FullURI is correct, both in content and formatting.
PowerShell v5.1 Windows 10