简体   繁体   English

AWS SDK .NET Fargate ECS 获取当前任务的 ARN

[英]AWS SDK .NET Fargate ECS Get ARN of current task

We're using AWS fargate, and run services with a bunch of task.我们正在使用 AWS fargate,并通过一系列任务运行服务。 For logging purposes i would like to know the ARN of the "current Task" (the task that the code is running on).出于记录目的,我想知道“当前任务”(代码正在运行的任务)的 ARN。 Before we were using EC2 and i could the AWS SDK for .NET (Amazon.Util.EC2InstanceMetadata.InstanceId) to get it.在我们使用 EC2 之前,我可以使用适用于 .NET 的 AWS 开发工具包 (Amazon.Util.EC2InstanceMetadata.InstanceId) 来获取它。

So far i haven't found anything that could give met the ID / ARN of the task in the SDK or otherwise.到目前为止,我还没有发现任何可以满足 SDK 中任务的 ID/ARN 或其他的东西。 Anyone aware of a way to retrieve this information?有人知道检索这些信息的方法吗?

To perhaps make it more clear which task ID / ARN i mean:为了更清楚地说明我的意思是哪个任务 ID / ARN: 在此处输入图片说明

In boto3 the python3 SDK, it have list_tasks(**kwargs) as documented here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.list_tasks在 boto3 python3 SDK 中,它具有list_tasks(**kwargs) ,如此处所述: https : list_tasks(**kwargs)

Request Syntax请求语法

response = client.list_tasks(
    cluster='string',
    containerInstance='string',
    family='string',
    nextToken='string',
    maxResults=123,
    startedBy='string',
    serviceName='string',
    desiredStatus='RUNNING'|'PENDING'|'STOPPED',
    launchType='EC2'|'FARGATE'
)

Not a .NET person but this might be what you are looking for不是 .NET 人,但这可能是您正在寻找的

https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/ECS/MECSListTasksListTasksRequest.html https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/ECS/MECSListTasksListTasksRequest.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM