Microsoft announced built-in container support for the .NET SDK. The announcement states,Containers have become one of the easiest ways to distribute and run a wide range of applications and services in the cloud. The .NET runtime has been hardened for containers a few years ago. Developers can now create containerized versions of their applications by using dotnet publish. “Container images are now an output type supported by the .NET SDK”.

In the current initial preview stage, Microsoft is mainly focusing on the deployment of Linux-x64 images; Windows images and support for other architectures are still planned.

Of course, there are still some missing features in the preview stage. Microsoft says it has yet to implement support for authentication; this support is critical for many users and one of their highest priorities.In the meantime, Microsoft recommends that developers can push to their local Docker daemon and then usedocker taganddocker pushPush the generated image to the planned destination.


name: Containerize ASP.NET Core application

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup .NET SDK
        uses: actions/setup-dotnet@v2
      # Package the app into a linux-x64 container based on the dotnet/aspnet image
      - name: Publish
        run: dotnet publish --os linux --arch x64 --configuration Release -p:PublishProfile=DefaultContainer
      # Because we don't yet support pushing to authenticated registries, we have to use docker to
      # login, tag and push the image. In the future none of these steps will be required!
      # 1. Login to our registry so we can push the image. Could use a raw docker command as well.
      - name: Docker Login
        uses: actions-hub/docker/login@master
        env:
          DOCKER_REGISTRY_URL: sdkcontainerdemo.azurecr.io
          DOCKER_USERNAME: ${{ secrets.ACR_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.ACR_PAT }}
      # 2. Use the tag command to rename the local container to match our Azure Container Registry URL
      - name: Tag built container with Azure Container Registry url
        uses: actions-hub/docker/cli@master
        with:
          args: tag sdk-container-demo:1.0.0 sdkcontainerdemo.azurecr.io/baronfel/sdk-container-demo:latest
      # 3. Push the renamed container to ACR.
      - name: Push built container to Azure Container Registry
        uses: actions-hub/docker/cli@master
        with:
          args: push sdkcontainerdemo.azurecr.io/baronfel/sdk-container-demo:latest

Next, release candidates for the .NET 7 software development platform will add new image metadata, support for pushing images to remote registries, and support for Windows images. .NET 7 is expected to be released as a production release in November.

“We also plan to integrate this work directly into the SDK throughout the release process. At that time, we will release the final version of the package on NuGet, which will warn you of the change and ask you to completely remove the package…We want those building Linux containers to try building them using the .NET SDK. I personally tried it locally – I had fun accessing some of my demo libraries and containerizing them with one command, I hope you all feel the same.

#Microsoft #Announces #Builtin #Container #Support #NET #SDK

Leave a Comment

Your email address will not be published. Required fields are marked *