在azure批处理节点中安装python包

在azure批处理节点中安装python包,python,linux,azure,Python,Linux,Azure,如何在azure批处理节点中安装python包,如pip安装azure存储blob。我试图在start task中编写该命令,但导致stark任务失败?定义池时,必须指定池启动任务。创建并加入池时(或重新启动、重新映像时),此启动任务将在每个节点上运行 您可以在游泳池下的控制台中执行此操作。或者,如果您使用了Python,请这样做(这是一个示例,根据需要进行调整!)。看看task_commands变量是如何定义的(需要curl): 免责声明:基于Microsoft,请查阅,它将帮助您开始 Sta

如何在azure批处理节点中安装python包,如pip安装azure存储blob。我试图在start task中编写该命令,但导致stark任务失败?

定义池时,必须指定池启动任务。创建并加入池时(或重新启动、重新映像时),此启动任务将在每个节点上运行

您可以在游泳池下的控制台中执行此操作。或者,如果您使用了Python,请这样做(这是一个示例,根据需要进行调整!)。看看task_commands变量是如何定义的(需要curl):


免责声明:基于Microsoft,请查阅,它将帮助您开始

Stack Overflow是一个关于编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参见帮助中心中的。也许是或者会是一个更好的问题。我不同意@jww,Azure的用法是编程,尤其是批处理(如果用户使用CLI来定义其infra,而不仅仅是web界面的话)。我一直想知道,在SO中是否存在与开发软件安装相关的问题?通过将python编译为.exe来修复它。感谢您的回复:)我想知道如何在节点上运行自定义python脚本。文档中的示例仅显示如何使用系统命令(如
cat
或Ubuntu pkg,如
ffmpeg
),而不是您自己的python代码。现在,我了解了如何在创建池时使用
task\u命令来上传我们自己的脚本,然后在任务中使用它。谢谢。
def create_pool(batch_service_client, pool_id,
            resource_files, publisher, offer, sku):
"""
Creates a pool of compute nodes with the specified OS settings.

:param batch_service_client: A Batch service client.
:type batch_service_client: `azure.batch.BatchServiceClient`
:param str pool_id: An ID for the new pool.
:param list resource_files: A collection of resource files for the pool's
start task.
:param str publisher: Marketplace image publisher
:param str offer: Marketplace image offer
:param str sku: Marketplace image sku
"""
print('Creating pool [{}]...'.format(pool_id))

# Create a new pool of Linux compute nodes using an Azure Virtual Machines
# Marketplace image. For more information about creating pools of Linux
# nodes, see:
# https://azure.microsoft.com/documentation/articles/batch-linux-nodes/

# Specify the commands for the pool's start task. The start task is run
# on each node as it joins the pool, and when it's rebooted or re-imaged.
# We use the start task to prep the node for running our task script.
task_commands = [
    'cp -p {} $AZ_BATCH_NODE_SHARED_DIR'.format('YOUR-PYTHON-SCRIPT.py'),

    # Install pip
    'curl -fSsL https://bootstrap.pypa.io/get-pip.py | python',
    # Install the azure-storage module so that the task script can access
    # Azure Blob storage, pre-cryptography version
    'pip install azure-storage==0.32.0']

# Get the node agent SKU and image reference for the virtual machine
# configuration.
# For more information about the virtual machine configuration, see:
# https://azure.microsoft.com/documentation/articles/batch-linux-nodes/
sku_to_use, image_ref_to_use = \
    helpers.select_latest_verified_vm_image_with_node_agent_sku(
        batch_service_client, publisher, offer, sku)

user = batchmodels.AutoUserSpecification(
    scope=batchmodels.AutoUserScope.pool,
    elevation_level=batchmodels.ElevationLevel.admin)

new_pool = batch.models.PoolAddParameter(
    id=pool_id,
    virtual_machine_configuration=batchmodels.VirtualMachineConfiguration(
        image_reference=image_ref_to_use,
        node_agent_sku_id=sku_to_use),
    vm_size=_POOL_VM_SIZE,
    target_dedicated_nodes=_POOL_NODE_COUNT,
    start_task=batch.models.StartTask(
        command_line=helpers.wrap_commands_in_shell('linux',
                                                           task_commands),
        user_identity=batchmodels.UserIdentity(auto_user=user),
        wait_for_success=True,
        resource_files=resource_files),
)

try:
    batch_service_client.pool.add(new_pool)
except batchmodels.batch_error.BatchErrorException as err:
    print_batch_exception(err)
    raise