6

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

2
  • What version of Python SDK you're using? Can you share some code that you have written and tell us what's the issue you're running into. Commented May 10, 2020 at 2:04
  • I'm using notebooks.azure.com. I can't find a way to determine the SDK version. Regarding code, I've looked through all the samples mentioned here: learn.microsoft.com/en-us/samples/azure/azure-sdk-for-python/…. They all BEGIN with the connection string. I want to programmatically get it, not visit the azure portal gui. Is this possible? Commented May 10, 2020 at 2:23

1 Answer 1

10

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. My search criteria was wrong. get connection string azure blob storage python sdk yields no relevant results where get connection string azure blob storage azure cli lead me to the resources you suggest. Thank you!
Just found another method using [Azure Functions Core Tools][1]: func azure storage fetch-connection-string <StorageAccountName>. In case this is useful to someone. [1]: learn.microsoft.com/en-us/azure/azure-functions/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.