I am using a bash script ot upload a vhd to blob container in a storage account.
Steps:
I created a VM, Storage account, container with blob acces, and snapshot. From the VM created, I'm generating one SAS URI by taking a snapshot of the VM Disk.
After SAS URI is generated I'm trying to upload it to the storage account container using below CLI Command:
$sas=$(az snapshot grant-access --resource-group $resourceGroupName --name $snapshotName --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv)
I verified the value of $sas in the terminal it's printing the correct value.
But when try the below command.
az storage blob copy start --destination-blob $destinationVHDFileName --destination-container $storageContainerName --account-name $accountname --account-key $key --source-uri $sas
The SAS URI is a very large string. Wherever I see '&' in SAS URL the string after it gets separated.
Let's say the string is like `abc&sr63663&si74883&sig74848`
I'm getting the error:
sr is not recognized as internal or external command. Si is not recognized as internal or external command. Sig is not recognized as internal or external command.
Please help me with how I can pass the SAS URI properly in the last command mentioned through the bash script.
I tried to reproduce the same in my environment and got the same error as below:
To resolve the error, try wrapping the SAS token separately with single quotes followed by double quotes like below:
After executing the above script, vhd file uploaded to blob container successfully like below:
To confirm the above, Go to the Azure Portal and check the blob container like below:
Reference:
How to provide a SAS token to Azure CLI by Jon Tirjan