Skip to content

Instantly share code, notes, and snippets.

@shashankm28
Created July 27, 2020 19:36
Show Gist options
  • Save shashankm28/23cc7fd98155c997b86d05fa6d244cff to your computer and use it in GitHub Desktop.
Save shashankm28/23cc7fd98155c997b86d05fa6d244cff to your computer and use it in GitHub Desktop.
Connect to Azure Container using Connection String
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
def azure_connect_conn_string(source_container_connection_string, source_container_name):
try:
blob_source_service_client = BlobServiceClient.from_connection_string(source_container_connection_string)
source_container_client = blob_source_service_client.get_container_client(source_container_name)
print ("Connection String -- Connected.")
return source_container_client
except Exception as ex:
print ("Error: " + str(ex))
def main():
try:
azure_connection_string = input ('Please enter Container connection string: ')
container_name = input ('Please enter Container name: ')
## Connection String
connection_instance = azure_connect_conn_string(azure_connection_string, 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