Connect to azure storage (blob) using python

  22 Dec 2018
   azure, python

The following code snippets are on creating a connection to Azure Blob Storage using Python with account access key.
For more details on Azure Blob Storage and generating the access key, visit :
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python


Blob Service Object

# Import the required modules
from azure.storage.blob import BlockBlobService

# Create the BlockBlobService object, which points to the Blob service in your storage account
block_blob_service = BlockBlobService(account_name = 'Storage-Account-Name',
				      account_key = 'Storage-Account-Key')
'''
Please visit here to check the list of operations can be performed on the blob service object :   
(https://azure-storage.readthedocs.io/)
'''

  Connect to azure datalake store using python

  20 Dec 2018
   azure, python

The following code snippets are on creating a connection to Azure Data Lake Storage Gen1 using Python with Service-to-Service authentication with client secret and client id.
Follow the link, for more details on different ways to connect to Azure Data Lake Storage Gen1.


Authenticate

# Import the required modules
from azure.datalake.store import core, lib

# Define the parameters needed to authenticate using client secret
token = lib.auth(tenant_id = 'TENANT',
                 client_secret = 'SECRET',
                 client_id = 'ID')

# Create a filesystem client object for the Azure Data Lake Store name (ADLS)
adl = core.AzureDLFileSystem(token, store_name='ADLS Account Name')

'''
Please visit here to check the list of operations ADLS filesystem client can perform -
(https://azure-datalake-store.readthedocs.io/en/latest/api.html#azure.datalake.store.core.AzureDLFileSystem)
'''