def create_blob_from_url(storage_connection_string,container_name): try: # urls to fetch into blob storage url_list = get_random_images() # Instantiate a new BlobServiceClient and a new ContainerClient blob_service_client = BlobServiceClient.from_connection_string(storage_connection_string) container_client = blob_service_client.get_container_client(container_name) for u in url_list: # Download file from url then upload blob file r = requests.get(u, stream = True) if r.status_code == 200: r.raw.decode_content = True blob_client = container_client.get_blob_client(get_filename_from_url(u)) blob_client.upload_blob(r.raw,overwrite=True) return True except Exception as e: print(e.message, e.args) return False