我正在尝试将大量Azure资源从Azure资源组移动到Azure资源组
我的代码如下所示:
for i in resource_client.resources.list(filter=f"tagName eq 'run_id' and tagValue eq '{RUN_ID}'"):
print_item(i)
ids.append(i.id)
targetRG = resource_client.resource_groups.get(resource_group_name=DELETE_GROUP_NAME)
for id in ids:
try:
poller = resource_client.resources.move_resources(source_resource_group_name=SOURCE_GROUP_NAME, target_resource_group=targetRG.id, resources=id)
rg_move_result = poller.result()
except:
pass
我不希望使用第二个循环,而是批量执行,但是如果在移动过程中出现任何错误,它就会失败。有没有办法做到这一点,跳过错误
基本上,您可以尝试使用下面的代码结构来实现您想要的:
顺便说一下,如果您检查源代码,“move_resources()”中的“resources”类型应该是列表类型
相关问题 更多 >
编程相关推荐