Skip to main content

Azure Utilities

Project description

Azure Utils

PyPI version License: MIT

Azure Utilities for python

Documentation

Technical documentation can be found here.

Setup

Make sure you have Python 3.6.x (or higher) installed on your system. You can download it here.

Recommended (but Optional) -> Expand this section to setup and activate a virtual environment.
  • Install (or upgrade) virtualenv:
python3 -m pip install --upgrade virtualenv
  • Create your virtualenv named venv:
python3 -m virtualenv venv
  • Activate your virtual environment
    • On Unix (Mac or Linux):
    source venv/bin/activate
    
    • On Windows:
    venv\scripts\activate
    
pip install azure_utils

Basic Usage

import os, sys
from azure_utils.blob_storage import AZContainer

# Get the working directory of this file
wd=os.path.abspath(os.path.dirname(sys.argv[0]))

# Create a container object
az = AZContainer(
    account_url="https://<account_name>.blob.core.windows.net",
    account_key="<account_key>",
    container_name="<container_name>"
)

# Get a list of all files in the container and print the first 5
files = az.list_files(remote_folderpath='/')
print(files[:5])

# Upload a file to the container
az.upload_file(
    remote_filepath='/test.csv',
    local_filepath=f'{wd}/test_data/upload/test.csv',
    overwrite=True
)

# Download the file from the container
az.download_file(
    remote_filepath='/test.csv',
    local_filepath=f'{wd}/test_data/download/test.csv',
    overwrite=True,
    smart_sync=True
)

# Delete the file from the container
az.delete_file(
    remote_filepath='/test.csv'
)

# Upload a folder to the container
az.sync_to_remote(
    remote_folderpath='/',
    local_folderpath=f'{wd}/test_data/upload/',
    overwrite=True,
)

# Download the folder from the container
az.sync_to_local(
    remote_folderpath='/',
    local_folderpath=f'{wd}/test_data/download/',
    overwrite=True,
    smart_sync=True,
)

# Delete all files in the container
az.delete_folder(
    remote_folderpath='/',
)

# Delete all local metadata
az.clear_local_meta(f'{wd}/test_data/')

Contributors:

  • Alice Zhao
  • Connor Makowski

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure_utils-0.4.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

azure_utils-0.4.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file azure_utils-0.4.0.tar.gz.

File metadata

  • Download URL: azure_utils-0.4.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for azure_utils-0.4.0.tar.gz
Algorithm Hash digest
SHA256 baa1eabd494dfe223e5678d48d7384d043408cdca38459b4653024b0614d8956
MD5 eb76f89074bd8ccc63125cce066b5074
BLAKE2b-256 535cab02618b0752524fc181593319938943b9ec51034894d9d5dd036041f4b4

See more details on using hashes here.

File details

Details for the file azure_utils-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: azure_utils-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for azure_utils-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22c4d0ac1ff54c3b0fdeddfdd2e9fca04b3c26ad9272d57de4ad3b26405c4903
MD5 390123abb35f918b407b210989bff6bc
BLAKE2b-256 3df901c3da3a46e7561118e37a4c62facd3e019d1442de1bec1426b1c00d969f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page