wkaczurba

Dockerfile .NET on Ubuntu

Running non-Docker .dotnet on Ubuntu first.

Simply dotnet + name of dll should work but failed in my case.

Gotchas:

(Non-docker dotnet): When trying to directly use donet with DLLs on Ubuntu got apt packages mixed-up on 22.04

Here is ther fix: https://stackoverflow.com/questions/73753672/a-fatal-error-occurred-the-folder-usr-share-dotnet-host-fxr-does-not-exist

Dockerized Windows dotnet:

  1. example from AZ-204: Implement containerized solutions > Manage container images in Azure Container Registry > Explore elements of a Dockerfile

  2. my example: https://github.com/wkaczurba/BasicDotnet/commit/52b553041fb2a5d885d3ff227568837e4e328a75

Running Gotchas on Ubuntu:

Azure Container Registry (ACR)

Setting up ACR

Just create. SKUs: standard seems ok. Premium allows private access only + CMK encryption.

Enable admin access

Pushing into ACR

Logging-in

Make sure az command line is installed.

This one should be sufficient to log-in with OAuth:

Alternatively:

Tagging + pushing:

docker tag dotnetapp wk123.azurecr.io/dotnetapp
docker push wk123.azurecr.io/dotnetapp

where wk123 is repo’s name. Voila:

Permissions

Good description of permissions is here Azure Container Registry roles and permissions.

Particularly interesting role is AcrPush that allows just for pushing/pulling images.

Azure Instances

Creating Azure Instance:

Options for Image source:

Networking:

Advanced:

Just start…

LOGS are in Settings blade -> Containers -> [Container-name] -> Logs:

Azure Container Instance - logs

Docker - multistage build for dotnet.

Docker + dotnet: https://hub.docker.com/_/microsoft-dotnet

Single-stage:

FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY . .
EXPOSE 80
ENTRYPOINT ["dotnet", "BasicDotnet.dll"]

Multi-stage:

My working example:

FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
WORKDIR /source

COPY *.csproj ./
RUN dotnet restore

COPY . .
RUN dotnet publish -c Release -o out

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build /source/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "BasicDotnet.dll"]

Container group deployments

UDEMY: https://www.udemy.com/course/azure-certification-1/learn/lecture/31939138#overview

Microsoft docs/tutorial:

Tested and followed this one - all easy steps:

Blobs - lifecycle policy JSON:

Conditional headers for blob-service operations

You can specified what file you expect to get by supplying additional request headers like:

Time0based retention policies for immutable blob data

https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-time-based-retention-policy-overview

## Immutable leagl hold - overview

https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-legal-hold-overview