Retrieve blob storage connection string using az cli or python sdk?

Viewed 5045

Is there a python function to retrieve a blob storage account connection string?

  • If so, how is this accomplished?
  • If not, is there a way to retrieve a SAS token using az cli or python?

Thank you

1 Answers

If using CLI is an option, you can get connection string for a storage account by using az storage account show-connection-string command.

az storage account show-connection-string --name MyStorageAccount --resource-group MyResourceGroup --subscription MySubscription

To get Shared Access Signature for a blob, you can use az storage blob generate-sas command.

end=`date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ'`
az storage blob generate-sas -c myycontainer -n MyBlob --permissions r --expiry $end --https-only
Related