<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[The AWS Coder - Medium]]></title>
        <description><![CDATA[Explore using different AWS SDK/API for building Cloud Native applications - Medium]]></description>
        <link>https://medium.com/the-aws-coder?source=rss----9523e02b9dd8---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>The AWS Coder - Medium</title>
            <link>https://medium.com/the-aws-coder?source=rss----9523e02b9dd8---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 09:36:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/the-aws-coder" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Invoke AWS Lambda Function programmatically using .NET, C# and AWS Lambda SDK]]></title>
            <link>https://medium.com/the-aws-coder/invoke-aws-lambda-function-programmatically-using-net-c-and-aws-lambda-sdk-d573c8270d9c?source=rss----9523e02b9dd8---4</link>
            <guid isPermaLink="false">https://medium.com/p/d573c8270d9c</guid>
            <category><![CDATA[parallel-computing]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Adityanand Pasumarthi]]></dc:creator>
            <pubDate>Thu, 03 Mar 2022 14:49:54 GMT</pubDate>
            <atom:updated>2022-03-03T14:49:08.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*F5_80y5i9b8B4LYmtr-0iQ.jpeg" /><figcaption>AWS Lambda Function Invocation</figcaption></figure><h3>Invoke AWS Lambda Function programmatically using .NET, C# and AWS Lambda SDK</h3><p>In this small story I’ll show you how to invoke an AWS Lambda Function programmatically using .NET, C# and AWS Lambda SDK.</p><p>AWS Lambda is a serverless platform that allows us to run our application docker images or raw code on a dynamically assigned container/compute fleet inside AWS. This allows us to focus on our code functionality and let AWS take care of spinning up required compute resources, which automatically scales up and down based on the load on our code.</p><p>I created a small AWS Lambda Function in .NET &amp; C#. The function takes in a number and returns true if the number is a prime number, and returns false if the number is not a prime number. This sample function code is then packaged into a Docker image, which then is uploaded to AWS as Lambda Function using Visual Studio 2019. The sample has a console program, which calls into our AWS Lambda Function that was uploaded to our AWS account.</p><p>Below is the link to the sample on GitHub. You have to put your AWS related Api &amp; Secret Keys and other settings in the appsettings.json file in the console application project, based on your AWS account configuration.</p><p><a href="https://github.com/apasumarthi1999/AWSLambdaDotNet">https://github.com/apasumarthi1999/AWSLambdaDotNet</a></p><p>Coming back our story, the console program invokes the AWS Lambda Function programmatically using AWS Lambda SDK. The console program tries to check for all prime numbers within a range of numbers.</p><blockquote>There are much much efficient ways of checking for prime numbers within a range of numbers. This sample code is designed this way to showcase how a AWS Lambda Function can be programmatically invoked, and how to use TPL (Task Parallel Library) of .NET to parallelize AWS Lambda Function invocations, where required and makes sense.</blockquote><p>Below is the prime number function and console program code. There are a few points to note in the console program code.</p><p>First, see how the Parallel for loop is used to call into the AWS Lambda Functions parallelly. This helps us verify the prime number in parallel. We did not use <strong>async/await</strong> in calling the AWS Lambda Function within the parallel loop. This is because, we want to wait until all the numbers (all the invocations) are verified. And if we use async action for the Parallel for loop, it will initiate the execution of all the numbers and come out before the actual AWS Lambda Function invocations are complete. So we use <strong>GetAwaiter</strong> and <strong>GetResult</strong> to wait for the completion of the AWS Lambda Function invocations.</p><p>Second, we used some global static variables to track the concurrent executions and max concurrent executions. These data points will show us, how many of the AWS Lambda Function invocations are happening in parallel at any given point of time. This is important because, we do not want to spin up more functions and hit resource limits on our AWS account and also we want to make sure we use the AWS Lambda Function resources efficiently. Since our prime number function is packaged as a Docker image, it takes a few hundred milliseconds to few seconds to spin up the compute resources to run our function. The more functions are invoked in parallel, the more docker image containers have to be spun up by AWS. This will take time and also incur some additional cost. So, by keeping the concurrency to a limited number, we ensure we re-use the function compute resources that are spun up by AWS for further invocations and thus make our function invocations faster. This also keeps the AWS cost in check (though minimal).</p><p>Finally below is the code for the prime number function…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9dd408312b7f2d9553339e7d85c18321/href">https://medium.com/media/9dd408312b7f2d9553339e7d85c18321/href</a></iframe><p>Below is the code for invoking the above AWS Lambda Function from a console program…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e2569b15f1ee78ae5cd26a522cd3128/href">https://medium.com/media/2e2569b15f1ee78ae5cd26a522cd3128/href</a></iframe><p>Happy AWS coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d573c8270d9c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-aws-coder/invoke-aws-lambda-function-programmatically-using-net-c-and-aws-lambda-sdk-d573c8270d9c">Invoke AWS Lambda Function programmatically using .NET, C# and AWS Lambda SDK</a> was originally published in <a href="https://medium.com/the-aws-coder">The AWS Coder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using AWS ECS Service Discovery for communication between Microservices in .NET & C#]]></title>
            <link>https://medium.com/the-aws-coder/using-aws-ecs-service-discovery-for-communication-between-microservices-in-net-c-550e406a8b71?source=rss----9523e02b9dd8---4</link>
            <guid isPermaLink="false">https://medium.com/p/550e406a8b71</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <category><![CDATA[service-discovery]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Adityanand Pasumarthi]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 18:46:04 GMT</pubDate>
            <atom:updated>2022-02-28T18:58:13.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using AWS ECS Service Discovery for communication between Microservices in .NET &amp; C#</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PJxec_YrA_Tpje8stWFn9w.jpeg" /></figure><p>AWS ECS Services allows us to build reliable and fault tolerant Microservices. In this story we will see how to create an AWS ECS Service (an Aggregator Service), which internally talks to two other services using AWS ECS Service Discovery. And, we will also create all the ECS Services programmatically using the ECS SDK.</p><p>First some backdrop on AWS ECS Services.</p><p>AWS ECS Tasks allow us to run dockerized applications within AWS Cloud. However for building reliable applications &amp; Microservices, we need to be able to monitor our tasks health and load, and ensure minimum and enough instances of the task are running based on application requirements. AWS ECS Service does exactly this. Read more about AWS ECS Services and how they fit into overall ECS architecture from below link…</p><p><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html">What is Amazon Elastic Container Service?</a></p><p>AWS ECS also comes with Service Discovery, which lets tasks communicate with each other using simple service names, irrespective of where they are running and how many of them are running. This is essential for Microservices architecture where Microservices have to talk to each other. One can use ELB/ALB for communication between the services, but it quickly becomes prohibitively expensive. Here is a good article on Service Discovery and how it helps in building reliable and cost effective inter task/service communication within your AWS infrastructure.</p><p><a href="https://aws.amazon.com/blogs/aws/amazon-ecs-service-discovery/">Amazon ECS Service Discovery | Amazon Web Services</a></p><p>It is recommended to read my other related stories on pushing a .NET Web API Docker image to AWS ECR Repository programmatically, creating a ECS Task definition out of the AWS ECR repository and running the ECS Task programmatically, for more detailed information on a few steps that we will cover in this story. Here are the related story links…</p><ul><li><a href="https://medium.com/the-aws-coder/pushing-a-local-docker-image-to-amazon-ecr-repository-using-net-5-c-and-aws-ecr-sdk-d5d5ce7c338a">Pushing a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK</a></li><li><a href="https://medium.com/the-aws-coder/create-and-run-aws-ecs-task-programmatically-using-net-5-c-aws-ecs-sdk-82b31df98fd3">Create and Run AWS ECS Task programmatically using .NET 5, C# &amp; AWS ECS SDK</a></li></ul><p>Now let us get back to our story. We will simulate a small book store scenario, where we will have a <strong>Dashboard</strong> microservice that fetches a user’s book purchases and book recommendations in a single service call. Purchases are managed by a <strong>Purchases</strong> microservice, while recommendations are managed by a <strong>Recommendations</strong> microservice. Dashboard service essentially acts as an aggregator of the information from the purchases and recommendation services.</p><blockquote>Note: In this sample, I’ll not focus on dependency injection and other aspects of a good microservice design. This sample is about using ECS Service Discovery to communicate between microservices. In the process we will cover how to efficiently call into multiple microservices using .NET TPL (Task.WhenAll) and async/await.</blockquote><p>Here are the steps that we will follow to achieve the inter-microservices communication using ECS Service Discovery.</p><ol><li>Define a AWS Cloud Map Namespace, which allows for discovery of services within a VPC.</li><li>Create a Purchases microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Purchases microservice to return the list of book purchase objects.</li><li>Create a AWS ECS Service for the Purchases microservice. Attach this service definition to the Cloud Map Namespace created in Step-1.</li><li>Create a Recommendations microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Recommendations microservice to return the list of book recommendation objects.</li><li>Create a AWS ECS Service for the Recommendations microservice. Attach this service definition to the Cloud Map Namespace created in Step-1.</li><li>Create a Dashboard microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Dashboard microservice to return a Dashboard object that has the list of purchases and list of recommendations fetched from the Purchases and Recommendations microservices.</li><li>Clean up the AWS resources.</li></ol><p>The working sample code (Visual Studio 2019 Solution) is available on the GitHub. Below is the link.</p><p><a href="https://github.com/apasumarthi1999/AWSECSServiceDotNet">https://github.com/apasumarthi1999/AWSECSServiceDotNet</a></p><p>You should have an AWS account with ECS cluster created with a VPC and appropriate security groups and subnets that can be accessed through Internet (to test our Web API). You also need an IAM user with programmatic access through Api Key and Secret Key with permissions to manage AWS ECS services and AWS CloudWatch Logs of your AWS account.</p><p>You have to put your AWS related Api &amp; Secret Keys and other settings in the appsettings.json file in the console application project, based on your AWS account configuration.</p><p><strong>Step-1:</strong> Define a AWS Cloud Map Namespace, which allows for discovery of services within a VPC.</p><p>Creating an AWS Cloud Map Namespace is easy using AWS Console. Just go to the Cloud Map service and create a namespace, which can be used for “API calls and DNS queries in VPCs”. Below is a sample screenshot.</p><figure><img alt="Creating a new Cloud Map Namespace using AWS Console." src="https://cdn-images-1.medium.com/max/975/1*w62uESAKpM8vFQLo0XAi7g.png" /></figure><p>Once the namespace is created, note the namespace id and put it in the “ServiceDiscoveryNamespaceId” setting in the appsettings.json file of the .NET console project in the solution.</p><p><strong>Steps-2 &amp; 3</strong></p><p>Create a Purchases microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Purchases microservice to return the list of book purchase objects.</p><p>Create a AWS ECS Service for the Purchases microservice. Attach this service definition to the Cloud Map Namespace created in Step-1.</p><p>Check out the <strong>PurchasesApi</strong> project in the sample solution for the Purchases microservice and the endpoint it exposes. Run the Docker file in the project, which creates a docker image of the Purchases microservice. This docker image is then used to create the AWS ECS Service for the Purchases microservice.</p><p><strong>Steps-4 &amp; 5</strong></p><p>Create a Recommendations microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Recommendations microservice to return the list of book recommendation objects.</p><p>Create a AWS ECS Service for the Recommendations microservice. Attach this service definition to the Cloud Map Namespace created in Step-1.</p><p>Check out the <strong>RecommendationsApi</strong> project in the sample solution for the Recommendations microservice and the endpoint it exposes. Run the Docker file in the project, which creates a docker image of the Recommendations microservice. This docker image is then used to create the AWS ECS Service for the Recommendations microservice.</p><p>Below is the code snippet from this sample’s .NET console project that creates the Purchases and Recommendations microservices and associate them with the Cloud Map namespace for service discovery.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/062dcc22940982e4b9264756ec34425c/href">https://medium.com/media/062dcc22940982e4b9264756ec34425c/href</a></iframe><p><strong>Step-6</strong></p><p>Create a Dashboard microservice using .NET ASP.NET Core Web API framework. Expose a simple HTTP GET endpoint in the Dashboard microservice to return a Dashboard object that has the list of purchases and list of recommendations fetched from the Purchases and Recommendations microservices.</p><p>The same method as shown in the above code snippet is used to create the Dashboard service, but with the ability to get the public IP of the service task, so that we can test the dashboard endpoint.</p><p>Below code snippet from the .NET console project of the sample solution demonstrates the usage of the above method for creating different services discussed in this story.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e6f93f4ef13d38fa9f9e0599e6e1e19/href">https://medium.com/media/4e6f93f4ef13d38fa9f9e0599e6e1e19/href</a></iframe><p>Finally we call the HTTP GET endpoint of the Dashboard service to fetch the purchases and recommendations data. Below is the code snippet from the .NET console project that does this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c71930eed3b683f63684ec175896a94e/href">https://medium.com/media/c71930eed3b683f63684ec175896a94e/href</a></iframe><p>The Dashboard service endpoint will then call into the Purchases and Recommendations microservices endpoints to gather the required information. Below is the implementation of the Dashboard service endpoint. As you can observe in the below code snippet, the dashboard service’s GetDashboardmethod calls into the Purchases and Recommendations microservices using the service name (<strong>purchases-svc</strong>, <strong>recommendations-svc</strong>) that we assigned to these services during ECS service creation along with the Cloud Map namespace name (<strong>ecom</strong>) that we created. This way we get a nice DNS like service endpoint access, without actually owning any domain names and using relatively costlier ELB/ALB solutions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/857e8ccdb38fcff657127deaefe2d3a1/href">https://medium.com/media/857e8ccdb38fcff657127deaefe2d3a1/href</a></iframe><blockquote>There is a small technique that is used in the above code snippet to call into the microservices. We used Task.WhenAll to await on the microservices tasks, thus allowing the two microservices to run in parallel and return results simultaneously. This improves the performance of the Dashboard service, while still getting the scalability benefits of using async/await.</blockquote><p><strong>Step-7</strong></p><p>Clean up the AWS resources.</p><p>This step has to be done manually after execution of this sample. So please carefully look at the AWS resources created in your account and clean them up accordingly. Below are the resources that would be created as part of running this sample.</p><ol><li>Cloud Map Namespace</li><li>Three ECS Services (DashboardApi, PurchasesApi, RecommendationsApi)</li><li>Three ECS Task Definitions</li><li>Three ECS Tasks (running)</li><li>Service Discovery entries that are created while creating the ECS Service definitions</li><li>Other resources like VPC, Subnets, Security Groups that you would have manually created for testing this sample</li></ol><p>Voila, we were able to create and test out inter-microservices communication using AWS ECS Services and Service Discovery.</p><p>Happy AWS coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=550e406a8b71" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-aws-coder/using-aws-ecs-service-discovery-for-communication-between-microservices-in-net-c-550e406a8b71">Using AWS ECS Service Discovery for communication between Microservices in .NET &amp; C#</a> was originally published in <a href="https://medium.com/the-aws-coder">The AWS Coder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create and Run AWS ECS Task programmatically using .NET 5, C# & AWS ECS SDK]]></title>
            <link>https://medium.com/the-aws-coder/create-and-run-aws-ecs-task-programmatically-using-net-5-c-aws-ecs-sdk-82b31df98fd3?source=rss----9523e02b9dd8---4</link>
            <guid isPermaLink="false">https://medium.com/p/82b31df98fd3</guid>
            <category><![CDATA[aws-ecr]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <dc:creator><![CDATA[Adityanand Pasumarthi]]></dc:creator>
            <pubDate>Wed, 23 Feb 2022 11:37:16 GMT</pubDate>
            <atom:updated>2022-03-06T15:59:17.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uUyzX6my_u6i8SsUtjCIqQ.jpeg" /><figcaption>Cloud Native Applications</figcaption></figure><h3>Create and Run AWS ECS Task programmatically using .NET 5, C# &amp; AWS ECS SDK</h3><p>Hello folks! In this story we will learn how to programmatically deploy a dockerized Web API to an AWS ECS Task, run it, access and test it, all in .NET 5 and C#.</p><p><strong>Prerequisites</strong></p><p>You should have basic knowledge of AWS EC2, ECR, ECS Cluster, ECS Tasks and CloudWatch Logs. Refer to AWS documentation for a thorough understanding of AWS ECS and its components.</p><p><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html">https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html</a></p><p>You should have an AWS account with ECS cluster created with a VPC and appropriate security groups and subnets that can be accessed through Internet (to test our Web API). You also need an IAM user with programmatic access through Api Key and Secret Key with permissions to manage AWS ECS services and AWS CloudWatch Logs of your AWS account.</p><p><strong>The Story…</strong></p><p>This sample Visual Studio 2019 solution has two projects. A simple ASP.NET Core Web API project with a simple controller, <strong>Echo</strong>, which has a <strong>HTTP Get</strong> endpoint to echo the message passed on to it. This ASP.NET Core Web API project has a docker file, which is used to build the docker image for the API. Second project is console application and is the core sample, which demonstrates the following…</p><ol><li>Create AWS ECR Repository using AWS ECR SDK</li><li>Push Web API docker image to the AWS ECR Repository</li><li>Create a CloudWatch Log Group using AWS CloudWatchLogs SDK</li><li>Create a ECS Task definition in the configured ECS Cluster using AWS ECS SDK. This Task definition uses the ECR repository reference and the log group reference</li><li>Launch/Start the ECS Task within the configured subnet and with configured security group (Enable Public IP for the Task while launching)</li><li>Get the Public IP of the running task container using AWS EC2 SDK</li><li>Call the echo endpoint with a custom message, which will be echoed back to our program</li><li>Stop the task container</li></ol><p>Here is the GitHub link to the sample…you have to put your AWS related Api &amp; Secret Keys and other settings in the appsettings.json file in the console application project, based on your AWS account configuration.</p><p><a href="https://github.com/apasumarthi1999/AWSECSTaskCreationDotNet">https://github.com/apasumarthi1999/AWSECSTaskCreationDotNet</a></p><p><strong>Step 1 &amp; 2:</strong></p><p>Create AWS ECR Repository using AWS ECR SDK.</p><p>Push Web API docker image to the AWS ECR Repository.</p><p>These steps are explained in detail in our other story (link given below).</p><p><a href="https://medium.com/the-aws-coder/pushing-a-local-docker-image-to-amazon-ecr-repository-using-net-5-c-and-aws-ecr-sdk-d5d5ce7c338a">Pushing a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK</a></p><p><strong>Step 3:</strong> Create a CloudWatch Log Group using AWS CloudWatchLogs SDK.</p><p>We want to enable CloudWatch Logs by default on any task to monitor and analyze it. Hence we need a Log group to be associated with a task definition. The code snippet below demonstrates creating a log group using AWS CloudWatchLogs SDK.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/499c069d54f3cb7cefa591a844a745a7/href">https://medium.com/media/499c069d54f3cb7cefa591a844a745a7/href</a></iframe><p><strong>Step 4:</strong> Create a ECS Task definition in the configured ECS Cluster using AWS ECS SDK. This Task definition use the ECR repository reference and the log group reference.</p><p>Creating a ECS Task definition requires the reference to the AWS ECR Repository where the docker image exists, from which the task container has to run. Task definition also requires the log group name (the log group should already exists, see Step 3). We will be creating a FARGATE Task, where the sourcing of appropriate compute resources will be taken care by ECS infrastructure. The code snippet below demonstrates this step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/033cf7a200102d257c946e7f45c4fa16/href">https://medium.com/media/033cf7a200102d257c946e7f45c4fa16/href</a></iframe><p><strong>Step 5 &amp; 6:</strong></p><p>Launch/Start the ECS Task within the configured subnet and with configured security group (Enable Public IP for the Task while launching).</p><p>Get the Public IP of the running task container using AWS EC2 SDK.</p><p>Now that we have the task defined and our docker image available in the AWS ECR, we can go ahead and launch the Task. When we launch a Task, ECS will create an instance of the docker container where our Web API docker image will be run. This is similar to having a small computer with a public IP running our Web API application. After launching the task, we wait till the Task is running and collect the Public IP assigned to our task container. Below code snippet demonstrates these two steps.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b470b7c3eeb6742eb3ff8c7d177f22/href">https://medium.com/media/66b470b7c3eeb6742eb3ff8c7d177f22/href</a></iframe><p><strong>Step 7 &amp; 8:</strong></p><p>Call the echo endpoint with a custom message, which will be echoed back to our program.</p><p>Stop the task container.</p><p>We make a simple HTTP client call into our Web API echo endpoint running inside our task container. In Step 6, we already obtained the task container public IP, so we just form appropriate URL and call it using the .NET HttpClient. Once we are done with the API call, we stop the task so that we don’t get billed by AWS, while we are not using the task container!! Below code snippet demonstrates these steps.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfbea8f7c9e824da57c35a1f3440e1a9/href">https://medium.com/media/cfbea8f7c9e824da57c35a1f3440e1a9/href</a></iframe><p>Voila, we are done with one nice task of dynamically spinning up containers with our Web API in cloud (AWS).</p><p>Happy AWS coding!</p><p>PS: There are better ways to manage Web API in AWS. We will cover those as improvements to what we saw here. But understanding the contents of this story will enable you to think of improvisations, and this story covers fundamental concepts that you need to be aware of as a AWS Cloud Native developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82b31df98fd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-aws-coder/create-and-run-aws-ecs-task-programmatically-using-net-5-c-aws-ecs-sdk-82b31df98fd3">Create and Run AWS ECS Task programmatically using .NET 5, C# &amp; AWS ECS SDK</a> was originally published in <a href="https://medium.com/the-aws-coder">The AWS Coder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pushing a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK]]></title>
            <link>https://medium.com/the-aws-coder/pushing-a-local-docker-image-to-amazon-ecr-repository-using-net-5-c-and-aws-ecr-sdk-d5d5ce7c338a?source=rss----9523e02b9dd8---4</link>
            <guid isPermaLink="false">https://medium.com/p/d5d5ce7c338a</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws-ecr]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Adityanand Pasumarthi]]></dc:creator>
            <pubDate>Tue, 22 Feb 2022 13:15:09 GMT</pubDate>
            <atom:updated>2022-02-22T14:46:44.703Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pushing a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Yla5YlWDUHQ10O1ZVXVnw.jpeg" /><figcaption>Cloud Native Development</figcaption></figure><p>Well, this is a small story on how to programmatically push a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK.</p><p>The working sample is available on GitHub at below address…You need an AWS account to run this sample. This story assumes you know how to create a AWS IAM user for programmatic access using combination of Api Key and Secret Key, and assign required permissions for the user.</p><p><a href="https://github.com/apasumarthi1999/DockerAWSECRPushDotNet">https://github.com/apasumarthi1999/DockerAWSECRPushDotNet</a></p><p>Here are few easy steps in which you can achieve this…</p><p>In your .NET 5 project, add a reference to <strong>Docker.DotNet</strong> package. You can find this from your Visual Studio package explorer. Here is a link to the package GitHub site.</p><p><a href="https://github.com/dotnet/Docker.DotNet">https://github.com/dotnet/Docker.DotNet</a></p><p>Add a reference to the AWSSDK.ECR. You can find this from your Visual Studio package explorer.</p><p>Assuming you have your docker image ready in your local docker repository, this sample follows the below steps to push it to your AWS ECR repository.</p><p><strong>Step 1:</strong> Get the name of the docker image as input.</p><p><strong>Step 2:</strong> Create a new ECR repository on AWS ECR in your AWS account, where the docker image needs to be pushed to. For this, you need to setup your AWS API Key and AWS Secret Key in the sample project’s <strong>appsettings.json</strong>. These keys need to have the permission to create ECR repositories and push docker images to the ECR in your AWS account. You also need to update the AWS ECR region in which you want to push the docker image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef317fb4aab2fe5d0fb3220662bd9633/href">https://medium.com/media/ef317fb4aab2fe5d0fb3220662bd9633/href</a></iframe><p><strong>Step 3:</strong> To push your docker image to the above created ECR repository, your docker engine need to authenticate with the Amazon ECR. For this we can generate a authorization token from your AWS ECR keys, which can act as a password for the docker engine when pushing the docker image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a73b1acd15ba0fa68de4b9abcf4d6d48/href">https://medium.com/media/a73b1acd15ba0fa68de4b9abcf4d6d48/href</a></iframe><p><strong>Step 4:</strong> Tag your local docker image with the ECR repository Uri that we created in Step 2. So that we can use the ECR repository Uri as repository name while pushing the given docker image to the ECR.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0048bfe46b2a96be8073bb741fceb6b/href">https://medium.com/media/f0048bfe46b2a96be8073bb741fceb6b/href</a></iframe><p><strong>Step 5:</strong> Push the docker image with the ECR repository Uri to the corresponding ECR Repository created in Step 2. The user name in the AuthConfig object, which is used for authorization with ECR, should always be “AWS” and the password is the access token obtained in Step 3. The ServerAddress property of the AuthConfig in the below code should be the endpoint we got in the response of the authorization request to ECR (in Step 3).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0343bdf12c65bc0902d6be1903b8a1c7/href">https://medium.com/media/0343bdf12c65bc0902d6be1903b8a1c7/href</a></iframe><p>Now the <strong>PushImageAsync</strong> method in the above code snippet will await until the push of the docker image is completed. Meanwhile we can track the progress by passing an object of a class that implements IProgress&lt;JSONMessage&gt;interface to the PushImageAsync method. For this, we implemented a place holder class named DockerPushProgress that simply prints the progress messages. You can fine tune this by examining more about the progress object that is coming into the Report method of the implemented class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2051a1847ba0fab106b443968ef9d959/href">https://medium.com/media/2051a1847ba0fab106b443968ef9d959/href</a></iframe><p>Voila, we are done pushing a local docker image to AWS ECR repository programmatically using .NET 5, C# and handy Docker.DotNet package. Happy AWS coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5d5ce7c338a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-aws-coder/pushing-a-local-docker-image-to-amazon-ecr-repository-using-net-5-c-and-aws-ecr-sdk-d5d5ce7c338a">Pushing a local docker image to Amazon ECR Repository using .NET 5, C# and AWS ECR SDK</a> was originally published in <a href="https://medium.com/the-aws-coder">The AWS Coder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>