Use the Azure Cli to access Azure storage using a SAS
Asked Answered
W

2

6

Is there a way of using a SAS (shared access signature) to access an Azure storage container from the CLI?

It's clearly possible using an account name and a key, or using a connection string. But I want to use the CLI in a script that should only be able to read from a container.

Whisenhunt answered 4/8, 2016 at 16:18 Comment(0)
K
6

The ability to list blobs with sas (via --sas command line parameter) has been around for a while.

The latest CLI (0.10.2) now has a --sas command line option when uploading/downloading blobs as well. So...

azure storage blob upload --sas <sas> -c <connection-string> ...
azure storage blob list --sas <sas> ...
azure storage blob download --sas <sas> ...
Katlin answered 4/8, 2016 at 16:29 Comment(1)
Future readers - note that the --sas argument takes only the sas parameters and signatures. Not the whole uri. Also, the sas contains characters that have to be escaped in some cases (%,& etc). Make sure you do that.Whisenhunt
J
3

In newest versions of Azure CLI:

az storage blob upload --connection-string "<your SAS connection string>"
az storage blob list --connection-string "<your SAS connection string>"
az storage blob download --connection-string "<your SAS connection string>"
Jer answered 13/6, 2021 at 22:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.