How to properly pass a SAS token argument to the Azure CLI

How to properly pass a SAS token argument to the Azure CLI

While playing around with the Azure CLI and Powershell Core 7.0 I encountered a strange situation, when trying to pass a SAS token to a parameter.

This was the offending command

az storage blob show
    --container-name <container name>
    --name training.txt
    --account-name <account name>
    --sas-token "spr=https&sv=2018-11-09&si=readpolicy&sr=b&sig=<the signature>"

Also using single-quotes for the SAS token did not work. It always returned with:

The specified resource does not exist. ErrorCode: ResourceNotFound

Der Befehl "sv" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Der Befehl "si" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Der Befehl "sr" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Der Befehl "sig" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

However I was sure, that there is nothing wrong with the resource. Executing the same command with the classic command prompt worked just fine. So there must be something wrong with the way I escape the token.

Thanks to Gaurav Mantri-AIS@Stackoverflow I was able to make it work.

The solution was to use the so-called stop parsing token, that I have never heard of before.

Adding this stop-parsing-token right in-front of the first parameter made work! Nice!

az storage blob show
    --%
    --container-name <container name>
    --name training.txt
    --account-name <account name>
    --sas-token "spr=https&sv=2018-11-09&si=readpolicy&sr=b&sig=<the signature>"