Created
July 27, 2020 20:27
-
-
Save shashankm28/6b444cba75924ae70b9ede5214dac47d to your computer and use it in GitHub Desktop.
Connect to Azure Container using SAS Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient | |
def azure_connect_sas_token(token, account_url, source_container_name): | |
try: | |
blob_source_service_client = BlobServiceClient(account_url = account_url, credential = token) | |
source_container_client = blob_source_service_client.get_container_client(source_container_name) | |
print ("SAS Token -- Connected.") | |
return source_container_client | |
except Exception as ex: | |
print ("Error: " + str(ex)) | |
def main(): | |
try: | |
azure_sas_token = input ('Please enter SAS Token: ') | |
azure_acc_url = input ('Please enter Account URL: ') | |
container_name = input ('Please enter Container name: ') | |
## SAS Token | |
connection_instance = azure_connect_sas_token(azure_sas_token, azure_acc_url, container_name) | |
print ('Done') | |
except Exception as ex: | |
print ('main | Error: ', ex) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment