This week's Reading Notes has a nice mix of topics, from a comparison of Docker sandboxes and containers that I've been waiting for, to updates on .NET 11, tips on choosing a coding harness, and a friendly nudge for anyone thinking about publishing their first technical article. Hope you find something here worth your time.
Suggestion of the week
Docker Sandboxes vs. Containers: Key Differences (Srini Sekaran, Oleg Selajev) - I was looking forward to a post like this for a while, and it paid off. Nice post that compares the 2 tools and gives scenarios for when to choose each.
Stop Copy-Pasting Your Life Into AI (Marlon Grech) - I don't know, even with code, we are scared about security, and we run our agent in a sandbox, which feels insecure and unsafe to open my calendar and email
MCP server vs REST API: When should you use each? (Ali Hamza Ansari) - When should you build an MCP server or stay with your API? Or when the app you build needs one of them? This post provides good answers and a nice overview of the differences.
Asynchronous Programming in C# (Sukhrob) - A good post that takes the time to explain the why.Why we should complexify our code to make it asynchronous.
ASP.NET Core CRUD with NoSQL: Part 3 (Matthew Groves) - We continue to learn, this time, a bit more about the sql+ and the create of the crud API.
Visual Studio on an ultra-wide monitor - Visual Studio Blog (Mads Kristensen) - It's not a "problem" I particularly have because I used 2 regular monitors, but I heard about it. It's really nice to see that so many possibilities are available to us.
Podcasts
Docker Desktop for Linux is Here! (DevOps and Docker Talk) - Great episode so much energy! Discussion about the brand new Docker Desktop for Linux, who to report bugs, ask for a new feature, and the DockerCon!
Épisode 15 - Gengis Khan (Les Pires Moments de l'Histoire) - I keep those episodes very preciously as a threat, and this one was such a good one! It's in French and the topic is the biggest empire that ever existed... No, it's the Romain.
Comparing Infrastructure-as-Code with Chris Klug (.NET Rocks!) - Terraform, Pulumi, ARM, and Bicep... All those are mentioned because it's all about Infrastructure-as-Code. Interesting talk about the different options we have.
Miscellaneous
Understanding the Role of a Developer Evangelist (Karl Hughes) - As a cloud advocate, I don't remember how often I explained what is my role. This 360-degree post covers all angles and provides a really good answer.
Already time to share new reading notes. Here is a list of all the articles, blog posts, and podcast episodes that catch my interest during the week.
You think you may have interesting content, share it!
Cloud
How to Upload a File to Azure Blob Storage (Claudio Bernasconi) - A nice tutorial that builds using .NET a little application to interact with Azure blob storage. And there is also a video.
Serverless Kubernetes with Azure Container Apps (Michael Ridland) - Now I understand not only how to create a container App but where does it fit in all the container services available in Azure. Very nice post.
Programming
.NET GitHub Actions: Intro to GitHub Actions for .NET (David Pine) - This is a great post to get started with GitHub action. Thus one is about .Net o but of course, many other languages are supported. Right now the only thing I want is to add more workflow and improve the existing ones...
Differences Between != And Is Not Operators in C# (Code Maze) - My first thought when I saw the title was well they are the same... And then I remember the differences. Great post the really take the time the explain the similarities and the differences.
A Practical Guide to Dapper (Camilo Reyes) - A nice tour of the functionalities of the tool. It's clear how it can be useful in a Data Access Layer pattern. Not to be confused with Dapr.
Serverless Deployment Best Practices (Fernando Medina Corey) - A nice post that shows some of the best practices for serverless and how AWS implements them.
Why jQuery is Obsolete and Time to Stop Using It (Chris Love) - Great post. I was a big user of jQuery, and these days I do less front end stuff, so it is nice to see how things have evolved and to understand the impact jQuery had.
Rust Governance: Scaling Empathy (Manish Goregaokar) - A friend recently introduced me to Rust. This post assumed we all already familiar to it, and talk about the current problems of this new language and potential solutions.
For a project I just started, I need to create Azure resources from code. In fact, I want to create an Azure Container Instance. I already know how to create a container from Logic Apps and Azure CLI/PowerShell, but I was looking to create it inside an Azure Function. After a quick research online, I found the Azure Management Libraries for .NET (aka Fluent API) a project available on Github that do just that (and so much more)!
In this post, I will share with you how this library work and the result of my test.
The Goal
For this demo, I will create a .Net Core console application that creates an Azure Containter Instance (ACI). After it should be easy to take this code and migrate to an Azure Function or anywhere else.
The Console Application
Let's create a simple console application with the following command: dotnet new console -o AzFluentDemo cd AzFluentDemo dotnet add package microsoft.azure.management.fluent The last command will use the nuget package available online an add it to our solution. Now we need a service principal so our application could access the Azure subscription. A since way to create one is the use Azure CLI az ad sp create-for-rbac --sdk-auth > my.azureauth This will create an Active Directory (AD) Service Principal (SP) and write the content into the file my.azureauth. Perfect, now open the solution, for this kind of project, I like to use Visual Studio Code so code . will do the work for me. Replace the content of the Program.cs file by the following code.
using System;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
namespace AzFluentDemo
{
class Program
{
static void Main(string[] args)
{
string authFilePath = "/home/frank/Dev/AzFluentDemo/my.azureauth";
string resourceGroupName = "cloud5mins";
string containerGroupName = "frank-containers";
string containerImage = "microsoft/aci-helloworld";
// Set Context
IAzure azure = Azure.Authenticate(authFilePath).WithDefaultSubscription();
ISubscription sub;
sub = azure.GetCurrentSubscription();
Console.WriteLine($"Authenticated with subscription '{sub.DisplayName}' (ID: {sub.SubscriptionId})");
// Create ResoureGroup
azure.ResourceGroups.Define(resourceGroupName)
.WithRegion(Region.USEast)
.Create();
// Create Container instance
IResourceGroup resGroup = azure.ResourceGroups.GetByName(resourceGroupName);
Region azureRegion = resGroup.Region;
// Create the container group
var containerGroup = azure.ContainerGroups.Define(containerGroupName)
.WithRegion(azureRegion)
.WithExistingResourceGroup(resourceGroupName)
.WithLinux()
.WithPublicImageRegistryOnly()
.WithoutVolume()
.DefineContainerInstance(containerGroupName + "-1")
.WithImage(containerImage)
.WithExternalTcpPort(80)
.WithCpuCoreCount(1.0)
.WithMemorySizeInGB(1)
.Attach()
.WithDnsPrefix(containerGroupName)
.Create();
Console.WriteLine($"Soon Available at http://{containerGroup.Fqdn}");
}
}
}
In the first row, I declare a few constants. The path of the service principal created earlier, resource group name, the container group name, and the image I will use. For this demo aci-helloworld. Then we get access with the Azure.Authenticate. Once we got access, it's y easy and the intellisense is fantastic! I don't think I need to explain the rest of the code as it already self-explanatory.
Got an Error?
While running you main in contour an error message complaining about the namespace not being registered or something like that ( I'm sorry I did not note the error message). You only need to register it with the command:
az provider register --namespace Microsoft.ContainerInstance
It will take a few minutes. To see if it's done you can execute this command:
az provider show -n Microsoft.ContainerInstance --query "registrationState"
Wrap it up
And voila! If you do a dotnet run after a minute or two, you will have a new web application running inside a container available from http://frank=containers.eastus.azurecontainer.io. It's now very easy to take that code and bring it to an Azure Function or in any .Net Core Application that runs anywhere (Linux, Windows, Mac Os, web, containers, etc.)!