简体   繁体   中英

Running an ECS task from .net desktop application

I am writing a simple desktop application using C# on Visual Studio. I am using the AWSSDK.Core and AWSSDK.ECS nuget packages. The access credentials are provided through ADFS CLI method. Since there is not much documentation regarding the .net SDK for ECS, I need some help regarding the Network Configuration parameters required to start a Fargate task using an existing task definition and cluster.

I have tried the example code provided in the AWS .net SDK documentation.

var response = client.RunTask(new RunTaskRequest 
{
    Cluster = "default",
    TaskDefinition = "sleep360:1"
});

List<Task> tasks = response.Tasks;

I would like to start a Fargate task from this desktop application with the Subnets and Security Groups defined within the AWSVPCConfiguration.

I think it should look something like this:

var response = client.RunTask(new RunTaskRequest 
{
    Cluster = "default",
    TaskDefinition = "sleep360:1"
    PlatformVersion = "LATEST",
    LaunchType = "FARGATE",
    NetworkConfiguration = new NetworkConfiguration
    {
        AwsvpcConfiguration = new AwsVpcConfiguration
        {
            Subnets = new List<string>() { "subnet-XXXXXXXX" },
            SecurityGroups = new List<string>() { "sg-XXXXXXXXXXXXXXXXX" },
            AssignPublicIp = AssignPublicIp.ENABLED
        }
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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