当我尝试使用Azure门户UI在特定虚拟网络子网中创建池时,它可以工作,我可以从这些计算节点访问同一子网上的其他VM。但是,如果我尝试使用Python SDK这样做:
new_pool = batch.models.PoolAddParameter(
id=pool_id,
virtual_machine_configuration=batch_models.VirtualMachineConfiguration(
image_reference=image_ref_to_use,
node_agent_sku_id=sku_to_use),
vm_size=constants._POOL_VM_SIZE,
target_dedicated_nodes=constants._POOL_NODE_COUNT,
max_tasks_per_node=2,
task_scheduling_policy=batch.models.TaskSchedulingPolicy(
node_fill_type=batch.models.ComputeNodeFillType.pack),
start_task=batch.models.StartTask(
command_line=azure_helper.wrap_commands_in_shell('linux', task_commands),
user_identity=batch_models.UserIdentity(auto_user=user),
wait_for_success=True,
resource_files=self.application_files),
network_configuration=batch_models.NetworkConfiguration(subnet_id=constants.AZURE_BATCH_SUBNET_ID),
)
try:
self.batch_client.pool.add(new_pool)
except batch_models.batch_error.BatchErrorException as err:
print_exception()
raise
它给了我azure.batch.models.batch_error.BatchErrorException: {'lang': u'en-US', 'value': u'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:xxxxxxxxxxxxxxxxxxxxxxx\nTime:2018-02-01T15:36:25.5107368Z'}
如果我在创建池时未指定network_configuration
参数,则它适用于Python SDK。我的子网ID的格式为/subscriptions/xxxxxxxxxxxxxxxx/resourceGroups/xxxxx-compute/providers/Microsoft.Network/virtualNetworks/xxxxx-compute-vnet/subnets/default
有人能指出我为什么会这样吗?手动创建池很麻烦,因为我要添加许多资源文件URL。
谢谢!
答案 0 :(得分:1)
Joining your compute pool with a Virtual Network requires authenticating with Azure Active Directory. Please see this article for more information. The AAD requirement is listed in the pre-requisites section of that article. Please review that article fully as it underscores other important requirements and restrictions when joining a pool with a virtual network.
You can see a sample of authenticating with AAD with the Python SDK here.