文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Amazon ECS 您好
下列程式碼範例示範如何使用 Amazon ECS。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 using Amazon.ECS; using Amazon.ECS.Model; using Microsoft.Extensions.Hosting; namespace ECSActions; public class HelloECS { static async System.Threading.Tasks.Task Main(string[] args) { // Use the AWS .NET Core Setup package to set up dependency injection for the Amazon ECS domain registration service. // Use your AWS profile name, or leave it blank to use the default profile. using var host = Host.CreateDefaultBuilder(args).Build(); // Now the client is available for injection. var amazonECSClient = new AmazonECSClient(); // You can use await and any of the async methods to get a response. var response = await amazonECSClient.ListClustersAsync(new ListClustersRequest { }); Console.WriteLine($"Hello Amazon ECS! Following are some cluster ARNS available in the your aws account"); Console.WriteLine(); foreach (var arn in response.ClusterArns.Take(5)) { Console.WriteLine($"\tARN: {arn}"); Console.WriteLine($"Cluster Name: {arn.Split("/").Last()}"); Console.WriteLine(); } } }
-
如需 API 詳細資訊,請參閱 ListClusters AWS SDK for .NET 參考中的 API。
-
基本概念
動作