0.Shared / 1.pre-requisites-ingestion(Python)
Loading...

Pre-Requisites

Define Azure Blob Storage Mount

storageAccountName = dbutils.secrets.get(scope="key-vault-secrets", key="adls-storageAccount-Name")
storageAccountAccessKey = dbutils.secrets.get(scope="key-vault-secrets", key="adls-storageAccount-AccessKey")
# Function to mount a storage container
def mountStorageContainer(storageAccount, storageAccountKey, storageContainer, blobMountPoint):
  print("Mounting {0} to {1}:".format(storageContainer, blobMountPoint))
  # Attempt mount only if the storage container is not already mounted at the mount point
  if not any(mount.mountPoint == blobMountPoint for mount in dbutils.fs.mounts()):
    print("....Container is not mounted; Attempting mounting now..")
    mountStatus = dbutils.fs.mount(
                  source = "wasbs://{0}@{1}.blob.core.windows.net/".format(storageContainer, storageAccount),
                  mount_point = blobMountPoint,
                  extra_configs = {"fs.azure.account.key.{0}.blob.core.windows.net".format(storageAccount): storageAccountKey})
    print("....Status of mount is: " + str(mountStatus))
  else:
    print("....Container is already mounted.")
    print() # Provide a blank line between mounts

Mount Bronze Zone

mountStorageContainer(storageAccountName,storageAccountAccessKey,"bronze","/mnt/bronze")