API Reference
- class ezazure.ezazure.Azure(config_fname: str = '.ezazure', *, check: bool = False)
Easy Azure interface for uploading/downloading files
- Parameters
- config_fname: str, optional, default=’.ezazure’
Configuration file, containing your azure connection string (which can be the actual connection string, or the name of a file that contains your connection string) and your azure container. Example:
connection_str: ~/secrets/azure container: litmon-private
containeris only the default storage container, and can be overwritten in theupload()anddownload()functions. If it’s not provided in this file, then you must supplycontainervariable inupload()anddownload().- check: bool, optional, default=False
If
config_fnamecannot be read on__init__(), andcheck==True, then throw an error. (Otherwise, errors are only thrown onupload()and :meth`download` calls.)By keeping
check==False, then you can have code that looks like this:from ezazure import Azure Azure().download(fname)
and your code will succeed if:
fnameexists locally (regardless of whether you have Azure credentials in yourconfig_fnamefile), orfnameexists on your cloud and you have Azure credentials in yourconfig_fnamefile.
This provides a tight cloud integration that still works even if you don’t have access to the cloud, but have the files locally.
- Attributes
- client: azure.storage.blob.BlobServiceClient
Client for interfacing with Azure
Methods
download(file, *[, container, regex, replace])Download file from Azure
upload(file, *[, container, regex, replace, ...])Upload file to Azure
- download(file: str, *, container: Optional[str] = None, regex: bool = False, replace: bool = False)
Download file from Azure
- Parameters
- file: str
file to download
- container: str, optional, default=None
if supplied, download from this container (instead of default container listed in
.ezazure)- regex: bool, optional, default=False
treat
fileas a regex expression. download all files that match. all files will be downloaded to the same directory.- replace: bool, optional, default=False
if
dest/fileexists locally, then skip the download
- Raises
- FileNotFoundError
If
filedoes not exist in Azure
- upload(file: str, *, container: Optional[str] = None, regex: bool = False, replace: bool = True, update_listing: bool = True)
Upload file to Azure
- Parameters
- file: str
file to upload. This file will be uploaded as
basename(file). (I.e. it will NOT be uploaded to a directory within the container, but rather to the container root level.)- container: str, optional, default=None
if supplied, download from this container (instead of default container listed in
.ezazure)- regex: bool, optional, default=False
treat
fileas a regex expression. upload all files that match. all files must be in the same directory.- replace: bool, optional, default=True
replace existing file on server if it exists
- update_listing: bool, optional, default=True
if True, and if there is public access to
container, then update directory listing (with_update_listing()) after uploading
- Raises
- FileNotFoundError
If the file cannot be found locally