Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from azure.storage.blob import BlockBlobService, PublicAccess
- import argparse
- #
- # Usage: python python/azure-sas-send-blob.py --account_name ursahealthstorage
- # --sas_token "st=2018...&se=2018...&sp=r...&sv=2018...&sr=c&sig=2S...E%3D"
- # --container_name ursahealth-datasource --local_filename /path/to/my_test.csv --blob_name my_test.csv
- #
- # Note that the SAS Token is the querystring of the SAS URL (i.e. everything after the ?)
- # You can use the blob_name parameter to rename the file into the container, but you probably won't want to
- #
- parser = argparse.ArgumentParser()
- parser.add_argument('--account_name')
- parser.add_argument('--sas_token')
- parser.add_argument('--container_name')
- parser.add_argument('--local_filename')
- parser.add_argument('--blob_name')
- cli_params = parser.parse_args()
- def main():
- try:
- block_blob_service = BlockBlobService(account_name=cli_params.account_name, sas_token=cli_params.sas_token)
- block_blob_service.create_blob_from_path(cli_params.container_name, cli_params.blob_name, cli_params.local_filename)
- print("Successfully sent file {}".format(cli_params.blob_name))
- except Exception as e:
- print(e)
- exit(1)
- main()
Add Comment
Please, Sign In to add comment