Skip to content
/ Michaël Hompus

When using a Docker Registry, like hub.docker.com, you will not often want to delete a published version of an image. You cannot know if someone, somewhere in the world is using that specific version. But when using a repository as part of your CI/CD pipeline, you might have lots of versions that are not used by anyone anymore. So, what if you want to clean the repository automatically? In this article, I will show how the delete images by tag, using PowerShell and the Docker Registry HTTP API V2.

When using a Docker Registry, like hub.docker.com, you will not often want to delete a published version of an image. You cannot know if someone, somewhere in the world is using that specific version.

But when using a repository as part of your CI/CD pipeline, you might have lots of versions that are not used by anyone anymore. So, what if you want to clean the repository automatically?

In this article, I will show how the delete images by tag, using PowerShell and the CNCF Distribution HTTP API V2. This API is implemented by registries, like the Azure Container Registry service.

read more…
/ Michaël Hompus

I use the MSTest Parser task in a Bamboo build plan to add a report of tests that were executed and their outcome. But sometimes you want to skip running tests. For example, you are focusing on other changes in your CI/CD pipeline and want to keep the feedback loop as short as possible. The problem is, if you don't run any tests, the parser task will fail. There are no configuration settings to influence this behavior or to disable the task conditionally. I could disable the task manually, but that would affect all other branches at the same time. So, I found it was time to create a quick work around.

I use the MSTest Parser task in a Bamboo build plan to add a report of tests that were executed and their outcome. But sometimes you want to skip running tests. For example, you are focusing on other changes in your CI/CD pipeline and want to keep the feedback loop as short as possible.

The problem is, if you do not run any tests, the parser task will fail. There are no configuration settings to influence this behavior or to disable the task conditionally. I could disable the task manually, but that would affect all other branches at the same time.

Bamboo complaining that no failed tests were found.
Bamboo complaining about not finding any failed tests… which would be a good case in my book

So, it was time to create a quick work around.

read more…
Filed under PowerShell
Last update:
/ Michaël Hompus

The Custom Vision service is one of the Azure Cognitive Services that is provided by Microsoft. With custom vision, you can train a model with your own image data. The portal provides a Prediction API for the trained model to classify an image you supply. There can be reasons why you might not want to use the online REST endpoint and you could prefer an offline model. To work with machine learning in .NET, we can use ML.NET. There are several tutorials how to use this framework. But none of them combine the use of the Bitmap class with a downloaded ONNX model from the custom vision portal. In this article I will walk through the steps to set up an application to classify bitmaps using a custom vision model with ML.NET.

The Custom Vision service is one of the Azure AI Services that is provided by Microsoft. With custom vision, you can train a model with your own image data. The portal provides a Prediction API for the trained model to classify an image you supply.

There can be reasons why you might not want to use the online REST endpoint. For example, when processing images from a video feed, performance, connectivity, security, and costs might be considerations why you could prefer an offline model.

To work with machine learning in .NET, we can use ML.NET, an open source and cross-platform framework. There are several tutorials how to use this framework. But none of them combine the Bitmap class with a downloaded ONNX model from the custom vision portal.

In this article I will walk through the steps to set up an application to classify bitmaps using a custom vision model with ML.NET.

read more…
/ Michaël Hompus

When trying to have an application work with an ONNX model I downloaded from the Microsoft Custom Vision portal, I got the following exception: TypeInitializationException: EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'. Searching for the error online did not yield any solutions. After solving the problem, I wanted to share the solution for anyone else running into the same exception.

When trying to have an application work with an ONNX model I downloaded from the Microsoft Custom Vision portal, I got the following exception:

System.TypeInitializationException: 'The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.'
EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'.

Searching for the error online did not yield any solutions.

After solving the problem, I wanted to share the solution for anyone else running into the same exception.

read more…
/ Michaël Hompus

Recently, I was using a YAML file for storing some data for a pet project. To work with this YAML in a .NET application, I use the excellent YamlDotNet library by Antoine Aubry. One of my properties was a URL. Deserializing went fine, but when serializing back to a YAML file, things were not going as intended. In this short article, I will explain how I did fix this.

Recently, I was using a YAML file for storing some data for a pet project. To work with this YAML in a .NET application, I use the excellent YamlDotNet library by Antoine Aubry.

One of my properties was a URL. Deserializing went fine, but when serializing back to a YAML file, things were not going as intended.

In this short article, I will explain how I did fix this.

The setup

I have a quite simple piece of YAML describing a website with a name and URL.

website:
name: Blog
url: https://blog.hompus.nl

To represent this in my application, I created a simple POCO.

public class Website {
public string Name { get; set; }
public Uri Url { get; set; }
}

Deserializing

When deserializing the file, this works completely as expected. As you can see in the VSCode debugger:

Deserialized data, as shown in the VSCode debugger

Serializing

Now I want to serialize the object back to YAML. However, it ends up looking quite different than before.

website:
name: Blog
url: &o0
absolutePath: /
absoluteUri: *o0
localPath: /
authority: blog.hompus.nl
hostNameType: Dns
isDefaultPort: true
pathAndQuery: /
segments:
- /
host: blog.hompus.nl
port: 443
query: ""
fragment: ""
scheme: https
originalString: https://blog.hompus.nl
dnsSafeHost: blog.hompus.nl
idnHost: blog.hompus.nl
isAbsoluteUri: true
userInfo: ""

This was not what I expected.

So how can we encourage YamlDotNet to store the property as a string?

YamlMember

The YamlMember attribute can solve this problem. It has the SerializeAs property that allows to set the Type that the serialize must use during serialization.

For this situation, I choose the String type.

public class Website {
public string Name { get; set; }
[YamlMember(typeof(string))]
public Uri Url { get; set; }
}

And when generated the YAML file again, it looks like how I intended it.

website:
name: Blog
url: https://blog.hompus.nl/
Filed under C#
Last update: