aztk/utils/helpers.py
def upload_file_to_container(container_name,
                             application_name,
                             file_path,
                             blob_client=None,
                             use_full_path=False,
                             node_path=None) -> batch_models.ResourceFile:
    """
    Uploads a local file to an Azure Blob storage container.
    :param blob_client: A blob service client.
    :type blocblob_clientk_blob_client: `azure.storage.blob.BlockBlobService`
    :param str container_name: The name of the Azure Blob storage container.
    :param str file_path: The local path to the file.
    :param str node_path: Path on the local node. By default will be the same as file_path
    :rtype: `azure.batch.models.ResourceFile`
    :return: A ResourceFile initialized with a SAS URL appropriate for Batch
    tasks.
    """
    file_path = normalize_path(file_path)
    blob_name = None
    if use_full_path:
        blob_name = file_path.strip("/")
    else:
        blob_name = os.path.basename(file_path)
        blob_path = application_name + "/" + blob_name

    if not node_path:
        node_path = blob_name

    blob_client.create_container(container_name, fail_on_exist=False)

    blob_client.create_blob_from_path(container_name, blob_path, file_path)

    sas_token = blob_client.generate_blob_shared_access_signature(
        container_name,
        blob_path,
        permission=blob.BlobPermissions.READ,
        expiry=datetime.datetime.utcnow() + datetime.timedelta(days=7),
    )

    sas_url = blob_client.make_blob_url(container_name, blob_path, sas_token=sas_token)

    return batch_models.ResourceFile(file_path=node_path, blob_source=sas_url)

    Uploads a local file to an Azure Blob storage container.
    :param blob_client: A blob service client.
    :type blocblob_clientk_blob_client: `azure.storage.blob.BlockBlobService`
    :param str container_name: The name of the Azure Blob storage container.
    :param str file_path: The local path to the file.
    :param str node_path: Path on the local node. By default will be the same as file_path
    :rtype: `azure.batch.models.ResourceFile`
    :return: A ResourceFile initialized with a SAS URL appropriate for Batch
    tasks.
    
Uploads a local file to an Azure Blob storage container.
Uploads a local file to an Azure Blob storage container .
def upload_file_to_container(container_name,
                             application_name,
                             file_path,
                             blob_client=None,
                             use_full_path=False,
                             node_path=None) -> batch_models.ResourceFile:
    file_path = normalize_path(file_path)
    blob_name = None
    if use_full_path:
        blob_name = file_path.strip("/")
    else:
        blob_name = os.path.basename(file_path)
        blob_path = application_name + "/" + blob_name
    if not node_path:
        node_path = blob_name
    blob_client.create_container(container_name, fail_on_exist=False)
    blob_client.create_blob_from_path(container_name, blob_path, file_path)
    sas_token = blob_client.generate_blob_shared_access_signature(
        container_name,
        blob_path,
        permission=blob.BlobPermissions.READ,
        expiry=datetime.datetime.utcnow() + datetime.timedelta(days=7),
    )
    sas_url = blob_client.make_blob_url(container_name, blob_path, sas_token=sas_token)
    return batch_models.ResourceFile(file_path=node_path, blob_source=sas_url)
def upload_file_to_container ( container_name , application_name , file_path , blob_client = None , use_full_path = False , node_path = None ) -> batch_models . ResourceFile : file_path = normalize_path ( file_path ) blob_name = None if use_full_path : blob_name = file_path . strip ( "/" ) else : blob_name = os . path . basename ( file_path ) blob_path = application_name + "/" + blob_name if not node_path : node_path = blob_name blob_client . create_container ( container_name , fail_on_exist = False ) blob_client . create_blob_from_path ( container_name , blob_path , file_path ) sas_token = blob_client . generate_blob_shared_access_signature ( container_name , blob_path , permission = blob . BlobPermissions . READ , expiry = datetime . datetime . utcnow ( ) + datetime . timedelta ( days = 7 ) , ) sas_url = blob_client . make_blob_url ( container_name , blob_path , sas_token = sas_token ) return batch_models . ResourceFile ( file_path = node_path , blob_source = sas_url )
Uploads a local file to an Azure Blob storage container.
Uploads a local file to an Azure Blob storage container .
"""
    Uploads a local file to an Azure Blob storage container.
    :param blob_client: A blob service client.
    :type blocblob_clientk_blob_client: `azure.storage.blob.BlockBlobService`
    :param str container_name: The name of the Azure Blob storage container.
    :param str file_path: The local path to the file.
    :param str node_path: Path on the local node. By default will be the same as file_path
    :rtype: `azure.batch.models.ResourceFile`
    :return: A ResourceFile initialized with a SAS URL appropriate for Batch
    tasks.
    """
A ResourceFile initialized with a SAS URL appropriate for Batch
tasks.
A ResourceFile initialized with a SAS URL appropriate for Batch tasks .
`azure.batch.models.ResourceFile`
container_name
The name of the Azure Blob storage container.
The name of the Azure Blob storage container .
application_name
file_path
The local path to the file.
The local path to the file .
blob_client
A blob service client.
A blob service client .
use_full_path
node_path
Path on the local node. By default will be the same as file_path
Path on the local node . By default will be the same as file_path