def run_azure(target, jobs, n=<NUM_LIT:1>, path='<STR_LIT:.>', delete=True, config=None):
if config is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif isinstance(config, str):<EOL><INDENT>if not os.path.isfile(config):<EOL><INDENT>raise FileNotFoundError('<STR_LIT>'.format(config))<EOL><DEDENT>config_filename = config<EOL>config = configparser.ConfigParser()<EOL>config.sections()<EOL>config.read(config_filename)<EOL>config.sections()<EOL><DEDENT>elif not isinstance(config, configparser.ConfigParser):<EOL><INDENT>raise ValueError('<STR_LIT>'.format(repr(config)))<EOL><DEDENT>if '<STR_LIT>' not in config:<EOL><INDENT>raise KeyError('<STR_LIT>')<EOL><DEDENT>for key in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if key not in config['<STR_LIT>']:<EOL><INDENT>raise KeyError('<STR_LIT>'.format(key))<EOL><DEDENT><DEDENT>_BATCH_ACCOUNT_NAME   = config['<STR_LIT>']['<STR_LIT>']<EOL>_BATCH_ACCOUNT_KEY    = config['<STR_LIT>']['<STR_LIT>']<EOL>_BATCH_ACCOUNT_URL    = config['<STR_LIT>']['<STR_LIT>']<EOL>_STORAGE_ACCOUNT_NAME = config['<STR_LIT>']['<STR_LIT>']<EOL>_STORAGE_ACCOUNT_KEY  = config['<STR_LIT>']['<STR_LIT>']<EOL>_POOL_NODE_COUNT      = config['<STR_LIT>']['<STR_LIT>']<EOL>_POOL_ID              = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>_POOL_VM_SIZE         = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>_NODE_OS_PUBLISHER    = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>_NODE_OS_OFFER        = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>_NODE_OS_SKU          = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>_JOB_ID               = config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>if not _POOL_NODE_COUNT.isdigit():<EOL><INDENT>raise ValueError('<STR_LIT>'.format(_POOL_NODE_COUNT))<EOL><DEDENT>proc_per_node = <NUM_LIT:2>  <EOL>nproc = int(_POOL_NODE_COUNT) * proc_per_node<EOL>code_header = """<STR_LIT>"""<EOL><INDENT>open(output_file, mode='<STR_LIT:wb>') as fout:<EOL><DEDENT>pickle.dump(res, fout, protocol=<NUM_LIT:2>)<EOL>eate the blob client using the container's SAS token.<EOL>is allows us to create a client that provides write<EOL>cess only to the container.<EOL>_client = azureblob.BlockBlobService(account_name=args.storageaccount,<EOL>sas_token=args.sastoken)<EOL>ut_file_path = os.path.realpath(output_file)<EOL>_client.create_blob_from_path(args.storagecontainer,<EOL>output_file,<EOL>output_file_path)<EOL>src = textwrap.dedent(inspect.getsource(target))<EOL>if re.match('<STR_LIT>', src.split('<STR_LIT:\n>')[<NUM_LIT:0>]) is not None:<EOL><INDENT>raise RuntimeError(<EOL>"<STR_LIT>")<EOL><DEDENT>code = code_header<EOL>code += src<EOL>code += '<STR_LIT>'.format(target.__name__)<EOL>code += code_footer<EOL>target = code<EOL>suffix = binascii.hexlify(os.urandom(<NUM_LIT:4>)).decode()<EOL>start_time = datetime.datetime.now().replace(microsecond=<NUM_LIT:0>)<EOL>_log.info('<STR_LIT>'.format(start_time))<EOL>if not os.path.isdir(path):<EOL><INDENT>os.mkdir(path)<EOL><DEDENT>task_file = '<STR_LIT>'.format(path, suffix)<EOL>with open(task_file, '<STR_LIT:w>') as fout:<EOL><INDENT>fout.write(target)<EOL><DEDENT>input_file_names = []<EOL>output_file_names = []<EOL>for i, job in enumerate(jobs):<EOL><INDENT>filename = '<STR_LIT>'.format(path, suffix, i)<EOL>input_file_names.append(filename)<EOL>for j in range(n):<EOL><INDENT>output_file_names.append('<STR_LIT>'.format(suffix, i, j + <NUM_LIT:1>))<EOL><DEDENT>with open(filename, mode='<STR_LIT:wb>') as fout:<EOL><INDENT>pickle.dump(job, fout, protocol=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>blob_client = azureblob.BlockBlobService(<EOL>account_name=_STORAGE_ACCOUNT_NAME,<EOL>account_key=_STORAGE_ACCOUNT_KEY)<EOL>n_jobs = -(-(len(jobs) * n) // nproc)  <EOL>_log.info('<STR_LIT>'.format(n_jobs))<EOL>res = None<EOL>try:<EOL><INDENT>app_container_name = '<STR_LIT>'.format(suffix)<EOL>input_container_name = '<STR_LIT>'.format(suffix)<EOL>output_container_name = '<STR_LIT>'.format(suffix)<EOL>blob_client.create_container(app_container_name, fail_on_exist=False)<EOL>blob_client.create_container(input_container_name, fail_on_exist=False)<EOL>blob_client.create_container(output_container_name, fail_on_exist=False)<EOL>application_file_paths = [os.path.realpath(task_file)]<EOL>input_file_paths = [os.path.realpath(filename) for filename in input_file_names]<EOL>application_files = [<EOL>upload_file_to_container(blob_client, app_container_name, file_path)<EOL>for file_path in application_file_paths]<EOL>input_files = [<EOL>upload_file_to_container(blob_client, input_container_name, file_path)<EOL>for file_path in input_file_paths]<EOL>output_container_sas_token = get_container_sas_token(<EOL>blob_client,<EOL>output_container_name,<EOL>azureblob.BlobPermissions.WRITE)<EOL>credentials = batchauth.SharedKeyCredentials(_BATCH_ACCOUNT_NAME,<EOL>_BATCH_ACCOUNT_KEY)<EOL>batch_client = batch.BatchServiceClient(<EOL>credentials,<EOL>batch_url=_BATCH_ACCOUNT_URL)<EOL>create_pool(batch_client,<EOL>_POOL_ID + '<STR_LIT:->' + suffix,<EOL>application_files,<EOL>_NODE_OS_PUBLISHER,<EOL>_NODE_OS_OFFER,<EOL>_NODE_OS_SKU,<EOL>task_file,<EOL>_POOL_VM_SIZE, _POOL_NODE_COUNT)<EOL>loads = []<EOL>for i, input_file in enumerate(input_files):<EOL><INDENT>for j, output_file in enumerate(output_file_names[i * n: (i + <NUM_LIT:1>) * n]):<EOL><INDENT>loads.append((input_file, output_file, i + <NUM_LIT:1>, j + <NUM_LIT:1>))<EOL><DEDENT><DEDENT>assert n_jobs == -(-len(loads) // nproc)  <EOL>job_names = []<EOL>for i in range(n_jobs):<EOL><INDENT>job_name = '<STR_LIT>'.format(_JOB_ID, suffix, i + <NUM_LIT:1>)<EOL>create_job(batch_client, job_name, _POOL_ID + '<STR_LIT:->' + suffix)<EOL>task_ids = add_tasks(batch_client,<EOL>job_name,<EOL>loads[i * nproc: (i + <NUM_LIT:1>) * nproc],<EOL>output_container_name,<EOL>output_container_sas_token,<EOL>task_file,<EOL>_STORAGE_ACCOUNT_NAME)<EOL>job_names.append((job_name, task_ids))<EOL><DEDENT>wait_for_tasks_to_complete(batch_client,<EOL>job_names,<EOL>datetime.timedelta(minutes=<NUM_LIT:20>))<EOL>_log.info("<STR_LIT>")<EOL>download_blobs_from_container(blob_client,<EOL>output_container_name,<EOL>os.path.abspath(path))<EOL>for job_id, task_ids in job_names:<EOL><INDENT>print_task_output(batch_client, job_id, task_ids)<EOL><DEDENT>end_time = datetime.datetime.now().replace(microsecond=<NUM_LIT:0>)<EOL>_log.info('<STR_LIT>'.format(end_time))<EOL>_log.info('<STR_LIT>'.format(end_time - start_time))<EOL>res = []<EOL>for output_file in output_file_names:<EOL><INDENT>with open(os.path.join(path, output_file), mode='<STR_LIT:rb>') as fin:<EOL><INDENT>res.append(pickle.load(fin))<EOL><DEDENT><DEDENT>res = [res[i * n: (i + <NUM_LIT:1>) * n] for i in range(len(jobs))]<EOL><DEDENT>finally:<EOL><INDENT>_log.info('<STR_LIT>')<EOL>blob_client.delete_container(app_container_name)<EOL>blob_client.delete_container(input_container_name)<EOL>blob_client.delete_container(output_container_name)<EOL>for i in range(n_jobs):<EOL><INDENT>job_name = '<STR_LIT>'.format(_JOB_ID, suffix, i + <NUM_LIT:1>)<EOL>_log.info('<STR_LIT>'.format(job_name))<EOL>batch_client.job.delete(job_name)<EOL><DEDENT>_log.info('<STR_LIT>')<EOL>batch_client.pool.delete(_POOL_ID + '<STR_LIT:->' + suffix)<EOL>if delete:<EOL><INDENT>_log.info('<STR_LIT>')<EOL>for filename in output_file_names:<EOL><INDENT>filename = os.path.join(path, filename)<EOL>if os.path.isfile(filename):<EOL><INDENT>os.remove(filename)<EOL><DEDENT><DEDENT>for filename in itertools.chain(input_file_paths, application_file_paths):<EOL><INDENT>if os.path.isfile(filename):<EOL><INDENT>os.remove(filename)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return res<EOL>
Execute a function for multiple sets of arguments on Microsoft Azure,
    and return the results as a list.

    :param function target: A target function.
    :param list jobs: A list of sets of arguments given to the target.
    :param int n: The number of repeats running the target. 1 as default.
    :param str path: A path to save temp files. The current path as default.
    :param bool delete: Delete temp files after finishing jobs, or not. True as default.
    :param config: str or configparser.ConfigParser. A config file. An example is the following:

    ```
    [azure]
    batch.name = foo
    batch.key = bar
    batch.url = hoge
    storage.name = fuga
    storage.key = spam
    pool.nodecount = 2
    # pool.id = MyPool
    # pool.vmsize = Standard_D11_v2
    # os.publisher = Canonical
    # os.offer = UbuntuServer
    # os.sku = 16
    # job.id = MyJob
    ```

    :return: A list of results corresponding the `jobs` list.
    :rtype: list