Configure CI/CD for Azure Container Instances using Azure / Azure DevOps Pipelines

Containers are fast becoming the preferred way to package, deploy, and manage cloud applications. Azure Container Instances offers the fastest and simplest way to run a container in Azure, without having to manage any virtual machines and without having to adopt a higher-level service.

Azure Container Instances is a great solution for any scenario that can operate in isolated containers, including simple applications, task automation, and build jobs. Also, Azure Container Instances supports the deployment of multiple containers onto a single host by using a container group aka pods in terms of Kubernetes. Multi-container container groups or Pods are useful when building an application sidecar for logging, monitoring, or any other configuration where a service needs a second attached process.
Continue reading “Configure CI/CD for Azure Container Instances using Azure / Azure DevOps Pipelines”

Troubleshooting ERROR: The subscription is not registered to use namespace ‘Microsoft.ContainerInstance’.

While trying to create the Azure Container Instances on one of the newly created Azure Subscription, we came across this strange error, “ERROR: The subscription is not registered to use namespace ‘Microsoft.ContainerInstance'”. So we checked our configuration and the way we were creating the Azure Containers, and it all seemed okay. So we dig a little around by using PowerShell, authenticate to Azure using Login-AzureRmAccount and fire few commands.

The first command we fired was classic Get-Command to check if there are any existing cmdlets to help with Azure Resources and sure enough, there it was:
Continue reading “Troubleshooting ERROR: The subscription is not registered to use namespace ‘Microsoft.ContainerInstance’.”

Save your changes temporarily in Git using Git Stash

This happens almost every now and then. You are in middle of working on some code changes, modified few files here and there and may be added new files. Now something else comes up urgently and you are asked to do it now. But you do not want to make a commit in middle of the work. In such a case, if you switch branch, your changes are carried over to the another branch as well. So you need a way to save your work temporarily. Fortunately, Git allows this functionality using what is known as Git Stash.

Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.
Continue reading “Save your changes temporarily in Git using Git Stash”

Fixing error with .gitignore file not ignoring files

This happens almost every now and then with the developers who are very new to the Git. I’m writing it down in the hope that if somehow the original post on stackoverflow is not available for one or other reasons, people can still find the solution. Also, even after fixing this for multiple times, I do not remember the exact commands, I still end up googling the solution. Sometimes, it takes a lot of time to find the original post as there are so many reasons for .gitignore file not working in intended ways. So the scenario is like this, that you are very new to Git or have some understanding of Git or you are very excited about an idea, you started coding on it, then you initialize and then commit your files. Continue reading “Fixing error with .gitignore file not ignoring files”

Use SSL Certificates for Dotnet Core Application in Docker Containers

Using SSL to secure incoming and outgoing traffic from your server is always recommended. When you are developing locally or testing on a server, whether it is Windows or Macintosh or some distribution of Linux like CentOS, fedora, Ubuntu etc, its easy to put the certificate in one of the local directories and then ask server to use the same. However this becomes a little bit different if you are using Containers. Since Docker is the most popular container technology, it has become almost synonymous with containers. When using containers, you can many choices:
1) Map a local volume containing certificate files to the container and then refer to it from inside container
2) Copy certificate directly inside Container during image build process and then refer to it Continue reading “Use SSL Certificates for Dotnet Core Application in Docker Containers”

Remove old docker images from Azure Container Registry

As part of the Continuous Integration process, new builds are generated which contains certain enhancements or modification or bugfixes. For a containerized application deployment, docker images are created as part of builds which then needs to be uploaded to one of the container registries. Over the time, the registry will get filled up. Also as one use more and more space on the container registry, one needs to pay more and more.

There are no inbuilt commands or utilities provided by Docker for this. You have to write complex scripts for doing it. Fortunately, in latest round of the Azure CLI update, Microsoft has added some commands to do this. However, it can be cumbersome to select and remove docker images one at a time.  Continue reading “Remove old docker images from Azure Container Registry”

Detecting if dotnet core app is running inside docker container

In old days (not so old, albeit like a one or two year(s) ago), we used to insert a docker environment variable like IS_DOCKER_CONTAINER using dockerfile in docker images. This was used to determine if an application is running inside a docker container or not. This helped to set certain attributes of the application like logging level and methods, modify certain environmental settings etc and helped controlling behavior of the application. It can also be useful in other situations like to determine whether you want to run selenium tests or not (as selenium web drivers would not be available inside docker container) to run as part of the integration testing.  Continue reading “Detecting if dotnet core app is running inside docker container”